-
Notifications
You must be signed in to change notification settings - Fork 2
101 lines (85 loc) · 2.54 KB
/
backend-dev-deploy.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
name: Kerdy Backend Dev Server CI/CD
on:
workflow_dispatch:
permissions:
contents: read
jobs:
build-and-upload:
runs-on: ubuntu-22.04
defaults:
run:
working-directory: backend/emm-sale
services:
mysql:
image: mysql:8.0.28
env:
MYSQL_USER: user
MYSQL_PASSWORD: password
MYSQL_ROOT_PASSWORD: 1234
MYSQL_DATABASE: kerdy
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- name: 백엔드 메인으로 checkout
uses: actions/checkout@v3
with:
ref: backend-main
- name: JDK 11로 설정
uses: actions/setup-java@v3
with:
java-version: 11
distribution: 'temurin'
- name: Gradle에 실행 권한 부여
run: chmod +x gradlew
- name: Gradle 캐싱
id: cache-gradle
uses: actions/cache@v3
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: keystore 생성
id: generate-keystore
run: |
echo "$KEY_STORE" > keystore.b64
base64 -d -i keystore.b64 > keystore.p12
- name: keystore 이동
id: cp-keystore
run: |
cp keystore.p12 src/main/resources/ssl
- name: gradle 빌드
run: ./gradlew clean build
- name: 디버깅용 경로 출력
id: cp-keystore
run: |
pwd
- name: jar artifact에 업로드
uses: actions/upload-artifact@v3
with:
name: BackendApplicationJar
path: backend/emm-sale/build/libs/*.jar
deploy:
runs-on: self-hosted
needs: build-and-upload
steps:
- name: 구버전 jar 삭제
run: rm -rf /home/ubuntu/backend/build/emm-sale-*.jar
- name: artifact에서 jar파일 다운 받기
uses: actions/download-artifact@v3
with:
name: BackendApplicationJar
path: /home/ubuntu/backend/build/
- name: 배포하기
run: /home/ubuntu/backend/build/deploy.sh
- name: 슬랙 메시지 보내기
uses: 8398a7/action-slack@v3
with:
mention: 'here'
if_mention: failure
status: ${{ job.status }}
fields: workflow,job,commit,message,ref,author,took
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
if: always()