Skip to content

Update deployment.yaml #17

Update deployment.yaml

Update deployment.yaml #17

Workflow file for this run

name: CICD TO ECS
on:
push:
branches:
- main
env:
AWS_REGION: ap-northeast-2
ECR_URL: public.ecr.aws/j6g5s0j0/cicd-test:kyh
jobs:
CI:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- name: JDK 17 설치
uses: actions/setup-java@v4
with:
distribution: 'oracle'
java-version: '17'
cache: 'gradle'
- name: Gradle 명령 실행 권한 부여
run: chmod +x ./gradlew
shell: bash
- name: Gradle로 프로젝트 Build
run: ./gradlew build -x test
- name: ECR login
run: aws ecr get-login-password | docker login --username AWS --password-stdin 534420079206.dkr.ecr.ap-northeast-2.amazonaws.com
- name: Container build
run: docker build -t ${{ env.ECR_URL }} .
- name: Container Push
run : docker push ${{ env.ECR_URL }}
CD:
name: Deploy
runs-on: ubuntu-latest
needs: CI
steps:
- name: Deploy to ECS
uses: aws-actions/amazon-ecs-deploy-action@v2
with:
cluster: cicd-test # ECS 클러스터 이름
service: cicd-test # ECS 서비스 이름
task-definition: first-run-task-definition:4 # 태스크 정의 이름과 revision (예: my-task:1)
wait-for-service-stability: false # 서비스 안정화 대기 여부 (true/false)