forked from codesquad-members-2023/FoodyMoody-team-06
-
Notifications
You must be signed in to change notification settings - Fork 3
58 lines (57 loc) · 2.02 KB
/
be-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
name: be-cd
on:
push:
branches:
- release
paths:
- 'be/**'
env:
ROOT_PATH: ${{ github.workspace }}/be
MAIN_RESOURCE_PATH: ${{ github.workspace }}/be/src/main/resources
TEST_RESOURCE_PATH: ${{ github.workspace }}/be/src/test/resources
jobs:
be-cd:
runs-on: ubuntu-latest
steps:
- name: 레포지토리를 체크아웃한다
uses: actions/checkout@v4
- name: 자바를 설치한다
uses: actions/setup-java@v3
with:
distribution: 'corretto'
java-version: '11'
- name: 설정파일을 추가한다
run: |
cd ${{ env.MAIN_RESOURCE_PATH }}
echo "${{ secrets.APPLICATION_AWS_YML }}" > application-aws.yml
echo "${{ secrets.APPLICATION_JWT_YML }}" > application-jwt.yml
echo "${{ secrets.APPLICATION_OAUTH_YML }}" > application-oauth.yml
- name: 어플리케이션을 빌드한다
run: |
chmod +x gradlew
./gradlew build
working-directory: ${{ env.ROOT_PATH }}
- name: 도커 허브에 로그인한다
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: 어플리케이션의 도커 이미지를 빌드하고 도커 허브에 푸시한다
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile.be
push: true
tags: ${{ secrets.BE_DOCKER_IMAGE_NAME }}
- name: 어플리케이션을 배포한다
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST_ADDRESS }}
username: ${{ secrets.HOST_USERNAME }}
key: ${{ secrets.HOST_KEY }}
port: ${{ secrets.HOST_PORT }}
script: |
sudo docker compose -f docker-compose-be-app.yml down -v
sudo docker compose -f docker-compose-be-app.yml pull
sudo docker compose -f docker-compose-be-app.yml up -d
sudo docker image prune -f