-
Notifications
You must be signed in to change notification settings - Fork 0
109 lines (92 loc) · 3.35 KB
/
prod_deploy.yml
File metadata and controls
109 lines (92 loc) · 3.35 KB
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
name: WONQ 프로덕션 CI/CD 워크플로우
on:
release:
types: [ published ]
permissions:
contents: read
actions: read
jobs:
build-docker-image:
runs-on: ubuntu-latest
steps:
- name: 코드 체크아웃
uses: actions/checkout@v3
- name: JDK 17 설정
uses: actions/setup-java@v3
with:
java-version: "17"
distribution: "temurin"
- name: secret.yml 파일 설정
run: |
echo "$SECRET_YML_CONTENT" > ./src/main/resources/secret.yml
env:
SECRET_YML_CONTENT: ${{ secrets.PROD_SECRET_YML }}
- name: Gradle 실행 권한 부여
run: chmod +x ./gradlew
- name: bootJar 빌드
run: ./gradlew bootJar
- name: Google Cloud 인증 설정
uses: google-github-actions/auth@v1
with:
credentials_json: ${{ secrets.GCP_SA_KEY }}
- name: Google Cloud CLI 설정
uses: google-github-actions/setup-gcloud@v1
- name: GCP Artifact Registry 인증
run: |
gcloud auth configure-docker asia-northeast3-docker.pkg.dev
- name: Docker 이미지 빌드 및 푸시
uses: docker/build-push-action@v5
with:
context: .
push: true
platforms: linux/amd64
tags: |
asia-northeast3-docker.pkg.dev/fisa-wonq-order/wonq-order/server:${{ github.event.release.tag_name }}
asia-northeast3-docker.pkg.dev/fisa-wonq-order/wonq-order/server:latest
- name: Slack 알림 (실패 시)
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
fields: repo,action,ref,job,took
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
if: failure()
update-k8s:
needs: build-docker-image
runs-on: ubuntu-latest
steps:
- name: 인프라 레포지토리 체크아웃
uses: actions/checkout@v2
with:
repository: WON-Q/infra
token: ${{ secrets.GIT_TOKEN }}
- name: 이미지 버전 업데이트
run: |
sed -i 's|asia-northeast3-docker.pkg.dev/fisa-wonq-order/wonq-order/server.*|asia-northeast3-docker.pkg.dev/fisa-wonq-order/wonq-order/server:${{ github.event.release.tag_name }}|' ./manifests/wonq-order/server/deployment.yml
- name: 변경사항 커밋 및 푸시
run: |
git config --global user.name "${{ secrets.GIT_USER_NAME }}"
git config --global user.email "${{ secrets.GIT_USER_EMAIL }}"
git add ./manifests/wonq-order/server/deployment.yml
git commit -m "Update: wonq-order/server 이미지 버전 수정 v${{ github.event.release.tag_name }} by GitHub Actions"
git push
- name: Slack 알림 (실패 시)
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
fields: repo,message,commit,author,action,eventName,ref,workflow,job,took
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
if: failure()
slack-notification:
needs: [ build-docker-image, update-k8s ]
runs-on: ubuntu-latest
steps:
- name: Slack 알림 (항상)
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
fields: repo,action,ref
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
if: always()