-
Notifications
You must be signed in to change notification settings - Fork 2
89 lines (78 loc) · 2.66 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
name: Kerdy Backend Dev Server CI/CD
on:
workflow_dispatch:
jobs:
build:
name: 빌드
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: workflow_dispatch에서 지정한 branch로 checkout
uses: actions/checkout@v3
with:
token: ${{ secrets.SUBMODULE_TOKEN }}
submodules: true
- name: JDK 11로 설정
uses: actions/setup-java@v3
with:
java-version: 11
distribution: 'corretto'
- name: Gradle에 실행 권한 부여
run: chmod +x gradlew
- name: Actions/Caches에 Gradle 라이브러리 캐싱
id: cache-gradle
uses: actions/cache@v3
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle-
# RestDocs의 index.html 업데이트 반영을 위해 2번 build하도록 함
- name: gradle 빌드
run: ./gradlew build && ./gradlew build
- name: 도커 빌더 생성 및 부팅
uses: docker/setup-buildx-action@v2
- name: 도커 허브에 로그인
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: 도커 이미지 빌드 및 푸시
uses: docker/build-push-action@v4
with:
context: backend/emm-sale
file: backend/emm-sale/Dockerfile-dev
platforms: linux/arm64/v8
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/kerdy-dev:latest
deploy:
needs: build
name: 배포
runs-on: [ self-hosted, label-dev ]
steps:
- name: 도커 실행
run: |
docker stop kerdy && docker rm kerdy && docker rmi ${{ secrets.DOCKERHUB_USERNAME }}/kerdy-dev
docker run -d -p 8080:8080 --name kerdy --network host ${{ secrets.DOCKERHUB_USERNAME }}/kerdy-dev
- 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()