ci: ECS 배포 스크립트 추가 #14
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: 배포 자동화 파이프라인 | |
on: | |
push: | |
branches: | |
- master | |
- ci/#4 #for testing !! | |
permissions: | |
contents: read | |
actions: read | |
id-token: write | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
token: ${{ secrets.GIT_TOKEN }} | |
submodules: true | |
- name: Setup Java 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'adopt' | |
- name: Update Git submodules | |
run: git submodule update --remote --recursive | |
- name: Configure AWS Credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
role-to-assume: arn:aws:iam::125183404358:role/VacgomGithubActionAssumeRole | |
aws-region: ap-northeast-2 | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v1 | |
- name: Invoke Gradle | |
uses: gradle/gradle-build-action@v2 | |
- name: Grant execute permission for gradlew | |
run: chmod +x gradlew | |
- name: Build, tag, and push image to Amazon ECR | |
env: | |
PROFILE: dev | |
IMAGE_REPO_URL: ${{ steps.login-ecr.outputs.registry }}/vacgom | |
IMAGE_TAG: ${{ github.sha }} | |
run: ./gradlew jib --parallel | |
- name: Download Task Definition | |
run: | | |
aws ecs describe-task-definition \ | |
--task-definition vacgom-taskdef \ | |
--query taskDefinition \ | |
> task-definition.json | |
- name: Update Task Definition | |
id: task-def | |
uses: aws-actions/amazon-ecs-render-task-definition@v1 | |
with: | |
task-definition: task-definition.json | |
container-name: backend | |
image: ${{ steps.login-ecr.outputs.registry }}/vacgom:${{ github.sha }} | |
- name: Deploy Amazon ECS task definition | |
uses: aws-actions/amazon-ecs-deploy-task-definition@v1 | |
with: | |
task-definition: ${{ steps.task-def.outputs.task-definition }} | |
service: vacgom-best-service | |
cluster: vacgom-cluster | |
wait-for-service-stability: true | |
- name: Get current time | |
uses: 1466587594/get-current-time@v2 | |
id: current-time | |
with: | |
format: YYYY-MM-DDTHH-mm-ss | |
utcOffset: "+09:00" | |
- name: Show Current Time | |
run: echo "CurrentTime=${{steps.current-time.outputs.formattedTime}}" |