-
Notifications
You must be signed in to change notification settings - Fork 0
61 lines (50 loc) · 1.68 KB
/
deploy.yaml
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
name: deploy
on:
push:
branches: [dev]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: 체크아웃
uses: actions/checkout@v4
with:
submodules: true
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
- name: 서브모듈 업데이트
run: |
git submodule update --remote
- name: JDK 11 설치
uses: actions/setup-java@v4
with:
distribution: 'corretto'
java-version: '11'
cache: 'gradle'
- name: Gradle에 실행 권한 부여
run: chmod +x gradlew
- name: 빌드
run: ./gradlew build -x test
- name: DockerHub 로그인
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Docker 이미지 빌드 & DockerHub에 Push
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/qtudy-server:latest
- name: EC2 서버에 배포
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.STG_SERVER_HOST }}
username: ${{ secrets.STG_SERVER_USERNAME }}
key: ${{ secrets.STG_SERVER_PEM_KEY }}
envs: GITHUB_SHA
script: |
sudo docker stop $(sudo docker ps -a -q)
sudo docker rm $(sudo docker ps -a -q)
sudo docker pull ${{secrets.DOCKERHUB_USERNAME}}/qtudy-server
sudo docker run -d -p 8080:8080 --network="host" --name qtudy-server-container ${{secrets.DOCKERHUB_USERNAME}}/qtudy-server
sudo docker image prune -f