-
Notifications
You must be signed in to change notification settings - Fork 7
95 lines (79 loc) · 2.71 KB
/
testAndDeploy.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
90
91
92
93
94
95
name: testAndDeploy
on:
pull_request_review:
types: [submitted]
branches: [ "be" ]
defaults:
run:
working-directory: ./BE/exceed
jobs:
build:
runs-on: ubuntu-22.04
permissions:
contents: read
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Cache Gradle
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Build with Gradle Wrapper
run: ./gradlew build
- name: Send docker-compose.yml
uses: appleboy/scp-action@master
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_KEY }}
source: ./BE/exceed/docker-compose.yml
target: /home/ubuntu/backend-deploy
- name: Send resources-develop-environment
uses: appleboy/scp-action@master
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_KEY }}
source: ./BE/exceed/resources/gaebaljip-develop-environment
target: /home/ubuntu/backend-deploy
- name: Create .env file
run: |
echo "${{ secrets.ENV_VARS }}" > .env
- name: Send env file
uses: appleboy/scp-action@master
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_KEY }}
source: ./BE/exceed/.env
target: /home/ubuntu/backend-deploy
- name: Docker Image Build
run: docker build -t ${{ secrets.DOCKER_HUB_USER_NAME }}/gaebaljip-dev:latest .
- name: Docker Hub Login
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USER_NAME }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
- name: docker Hub Push
run: docker push ${{ secrets.DOCKER_HUB_USER_NAME }}/gaebaljip-dev:latest
- name: SSH Deploy
uses: appleboy/[email protected]
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_KEY }}
script: |
cd backend-deploy/BE/exceed
sudo docker-compose down
sudo docker pull ${{ secrets.DOCKER_HUB_USER_NAME }}/gaebaljip-dev:latest
sudo docker-compose up --build -d
sudo docker image prune -a -f