-
Notifications
You must be signed in to change notification settings - Fork 0
147 lines (139 loc) · 4.89 KB
/
CD.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
name: 배포 자동화 파이프라인
on:
push:
branches:
- master
- develop
permissions:
contents: read
actions: read
id-token: write
jobs:
deploy_master:
runs-on: ubuntu-latest
name: Deploy to Amazon ECS (master)
if: github.ref == 'refs/heads/master'
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 }}_master
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 }}_master
- 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: Send Slack notification
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
author_name: 백곰
fields: repo,message,commit,author,action,eventName,ref,workflow,job,took
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
if: always()
deploy_develop:
runs-on: ubuntu-latest
name: Deploy to Amazon ECS (develop)
if: github.ref == 'refs/heads/develop'
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 }}_dev
run: ./gradlew jib --parallel
- name: Download Task Definition
run: |
aws ecs describe-task-definition \
--task-definition vacgom-taskdef-dev \
--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 }}_dev
- 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-service-dev
cluster: vacgom-cluster
wait-for-service-stability: true
- name: Send Slack notification
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
author_name: 백곰
fields: repo,message,commit,author,action,eventName,ref,workflow,job,took
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
if: always()