-
Notifications
You must be signed in to change notification settings - Fork 5
90 lines (77 loc) · 2.97 KB
/
server_cicd.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
# .github/workflows/ci-cd.yml
name: server CI/CD Pipeline
on:
push:
# paths:
# - "server/**"
branches:
- main
jobs:
deploy:
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Set up Gradle
uses: gradle/gradle-build-action@v3
with:
gradle-version: '8.8'
- name: Build with Gradle
run: |
cd server
./gradlew build -x test
- name: Deploy to Internal Server through Bastion Host
if: success()
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.GCP_INTERNAL_SERVER_VM_HOST }}
username: ${{ secrets.GCP_SERVER_VM_USER }}
key: ${{ secrets.GCP_INTERNAL_SERVER_SSH_PRIVATE_KEY }}
port: 22
proxy_host: ${{ secrets.GCP_SERVER_VM_HOST }}
proxy_username: ${{ secrets.GCP_SERVER_VM_USER }}
proxy_key: ${{ secrets.GCP_SERVER_SSH_PRIVATE_KEY }}
proxy_port: 22
script: |
sudo docker image prune -f
# sudo docker stop swdc-container || true
# sudo docker rm swdc-container || true
# cd /home/patturning2/deployment
# sudo docker build -t swdc-app .
# sudo docker run -d -p 8080:8080 --name swdc-container -v /mnt:/mnt swdc-app
- name: Deliver jar File to Internal Server through Bastion Host
if: success()
uses: appleboy/scp-action@v0.1.7
with:
host: ${{ secrets.GCP_INTERNAL_SERVER_VM_HOST }}
username: ${{ secrets.GCP_SERVER_VM_USER }}
key: ${{ secrets.GCP_INTERNAL_SERVER_SSH_PRIVATE_KEY }}
proxy_host: ${{ secrets.GCP_SERVER_VM_HOST }}
proxy_username: ${{ secrets.GCP_SERVER_VM_USER }}
proxy_key: ${{ secrets.GCP_SERVER_SSH_PRIVATE_KEY }}
source: server/build/libs/swdc-0.0.1-SNAPSHOT.jar
target: /home/patturning2/deployment/
- name: Deploy to Internal Server through Bastion Host
if: success()
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.GCP_INTERNAL_SERVER_VM_HOST }}
username: ${{ secrets.GCP_SERVER_VM_USER }}
key: ${{ secrets.GCP_INTERNAL_SERVER_SSH_PRIVATE_KEY }}
port: 22
proxy_host: ${{ secrets.GCP_SERVER_VM_HOST }}
proxy_username: ${{ secrets.GCP_SERVER_VM_USER }}
proxy_key: ${{ secrets.GCP_SERVER_SSH_PRIVATE_KEY }}
proxy_port: 22
script: |
sudo docker image prune -f
sudo docker stop swdc-container || true
sudo docker rm swdc-container || true
cd /home/patturning2/deployment
sudo docker build -t swdc-app .
sudo docker run -d -p 8080:8080 --name swdc-container -v /mnt:/mnt swdc-app