-
Notifications
You must be signed in to change notification settings - Fork 0
56 lines (47 loc) · 1.77 KB
/
backend-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
name: Secret Message Backend Prod Server CD
on:
workflow_dispatch:
jobs:
build:
name: 빌드
runs-on: ubuntu-22.04
steps:
- name: workflow_dispatch에서 지정한 branch로 checkout
uses: actions/checkout@v3
- name: JDK 17로 설정
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'corretto'
- name: Gradle에 실행 권한 부여
run: chmod +x gradlew
- name: gradle 빌드
run: ./gradlew build
- name: 도커 허브에 로그인
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: 도커 빌더 생성 및 부팅
uses: docker/setup-buildx-action@v2
- name: 도커 이미지 빌드 및 푸시
uses: docker/build-push-action@v4
with:
file: Dockerfile
context: .
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/uni-11th-team5:latest
deploy:
needs: build
name: 배포
runs-on: [ self-hosted, prod ]
steps:
- name: 실행중인 도커 제거
run:
sudo docker stop $(sudo docker ps -q --filter "publish=8080" 2>/dev/null) || true
- name: 도커 pull
run:
sudo docker pull ${{ secrets.DOCKERHUB_USERNAME }}/uni-11th-team5
- name: 새로 빌드한 도커 실행
run:
sudo nohup docker run -p 8080:8080 ${{ secrets.DOCKERHUB_USERNAME }}/uni-11th-team5 --DB_HOSTNAME=${{ secrets.DB_HOSTNAME }} --DB_PORT=${{ secrets.DB_PORT }} --DB_DATABASE=${{ secrets.DB_DATABASE }} --DB_USERNAME=${{ secrets.DB_USERNAME }} --DB_PASSWORD=${{ secrets.DB_PASSWORD }} --JWT_SECRET=${{ secrets.JWT_SECRET}} > ~/be-log.out 2>&1 &