Skip to content

Update deployment.yaml #25

Update deployment.yaml

Update deployment.yaml #25

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 --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws/j6g5s0j0
- 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: 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: Deploy to ECS
run: aws ecs update-service --cluster cicd-test --service cicd-test --task-definition first-run-task-definition:6 --force-new-deployment