-
Notifications
You must be signed in to change notification settings - Fork 2
67 lines (55 loc) · 2.25 KB
/
prod-cd.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
name: Deploy to PROD
on:
workflow_dispatch:
push:
branches: [ "prod" ]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: 저장소 Checkout
uses: actions/checkout@v4
- name: 자바 17 셋업
uses: actions/setup-java@v4
with:
java-version: '17'
cache: 'gradle'
distribution: 'corretto'
- name: 설정 파일 추가
run: |
cd ./src/main/resources/
cat <<EOF > application-prod.yml
${{ secrets.APPLICATION_PROD_YML }}
EOF
cat <<EOF > application-oauth.yml
${{ secrets.APPLICATION_OAUTH_YML }}
EOF
cat <<EOF > application-storage.yml
${{ secrets.APPLICATION_STORAGE_YML }}
EOF
- name: 애플리케이션 빌드
run: |
cd /home/runner/work/ListyWave-back/ListyWave-back/
./gradlew bootJar
- name: 도커 이미지 빌드
run: docker build -t ${{ secrets.DOCKER_HUB_USERNAME }}/${{ secrets.IMAGE_NAME }}:${{ secrets.PROD_TAG }} ./
- name: 도커 허브에 로그인
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
- name: 도커 허브에 Push
run: docker push ${{ secrets.DOCKER_HUB_USERNAME }}/${{ secrets.IMAGE_NAME }}:${{ secrets.PROD_TAG }}
- name: 인스턴스 접속 및 배포 스크립트 실행
uses: appleboy/[email protected]
with:
host: ${{ secrets.PROD_EC2_HOST }}
username: ${{ secrets.PROD_EC2_USERNAME }}
key: ${{ secrets.PROD_EC2_PASSWORD }}
port: ${{ secrets.PROD_EC2_PORT }}
script: |
docker stop "${{ secrets.PROD_CONTAINER_NAME }}"
docker rm -f "${{ secrets.PROD_CONTAINER_NAME }}"
docker rmi "${{ secrets.DOCKER_HUB_USERNAME }}/${{ secrets.IMAGE_NAME }}:${{ secrets.PROD_TAG }}"
docker pull "${{ secrets.DOCKER_HUB_USERNAME }}/${{ secrets.IMAGE_NAME }}:${{ secrets.PROD_TAG }}"
docker run -d -p 8080:8080 --name "${{ secrets.PROD_CONTAINER_NAME }}" "${{ secrets.DOCKER_HUB_USERNAME }}/${{ secrets.IMAGE_NAME }}:${{ secrets.PROD_TAG }}"