generated from Game-as-a-Service/Gaas-repo-template
-
Notifications
You must be signed in to change notification settings - Fork 1
48 lines (41 loc) · 1.48 KB
/
backend_pr_cd_job.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
name: Java CD
on:
push:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: maven
- name: Build with Maven
working-directory: packages/backend/
run: mvn package -DskipTests
- name: Move JAR and Dockerfile to workspace
run: |
mv packages/backend/spring/target/citadels-backend-0.0.1-SNAPSHOT.jar $GITHUB_WORKSPACE/citadels-backend-0.0.1-SNAPSHOT.jar
mv packages/backend/spring/Dockerfile $GITHUB_WORKSPACE/Dockerfile
mv packages/backend/spring/docker-compose.yml $GITHUB_WORKSPACE/docker-compose.yml
rm -rf packages docs README.md
- name: Deploy to Server
uses: easingthemes/ssh-deploy@main
env:
SSH_PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
REMOTE_HOST: ${{ secrets.HOST }}
REMOTE_USER: ${{ secrets.USERNAME }}
TARGET: ${{ secrets.TARGET_DIR }}/backend
- name: Executing remote ssh commands using ssh key
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.PRIVATE_KEY }}
port: ${{ secrets.PORT }}
script: |
cd ~/citadels/backend
sudo MONGO_URI=$MONGO_URI docker-compose up -d --build