-
Notifications
You must be signed in to change notification settings - Fork 0
107 lines (90 loc) · 3.14 KB
/
deploy.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
96
97
98
99
100
101
102
103
104
105
106
107
name: Deploy
on:
workflow_run:
workflows: [ CI ]
types: [ completed ]
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
outputs:
version: ${{ steps.vars.outputs.version }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: 'maven'
server-id: github-l3s-learnweb
- uses: actions/setup-node@v3
with:
node-version: 18
cache: 'npm'
- run: npm ci
- run: npm run build
- run: mvn --quiet -P prod,!local -Dmaven.test.skip=true install
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
- name: Read version
id: vars
run: echo "version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_OUTPUT
- uses: actions/upload-artifact@v3
with:
name: learnweb-war
path: target/Learnweb.war
if-no-files-found: error
deploy-dev:
runs-on: ubuntu-latest
needs: [ build ]
steps:
- uses: actions/download-artifact@v3
with:
name: learnweb-war
- name: Rename artifact
run: mv Learnweb.war dev##${{ needs.build.outputs.version }}.war
- name: Install SSH keys
uses: shimataro/ssh-key-action@v2
with:
name: id_ed25519
key: ${{ secrets.DEPLOY_PRIVATE_KEY }}
known_hosts: ${{ secrets.DEPLOY_KNOWN_HOSTS }}
config: |
Host bastion
HostName ${{ secrets.DEPLOY_JUMP_HOST }}
User ${{ secrets.DEPLOY_JUMP_USERNAME }}
Host learnweb
HostName ${{ secrets.DEPLOY_HOST }}
User ${{ secrets.DEPLOY_USERNAME }}
ProxyJump bastion
- name: Copy artifact to server
run: rsync -avzh dev##*.war learnweb:${{ secrets.DEPLOY_PATH }}/
deploy-prod:
runs-on: ubuntu-latest
if: startsWith(github.event.head_commit.message, 'chore') && endsWith(github.event.head_commit.message, 'version release')
needs: [ build ]
steps:
- uses: actions/download-artifact@v3
with:
name: learnweb-war
- name: Rename artifact
run: mv Learnweb.war ROOT##${{ needs.build.outputs.version }}.war
- name: Install SSH keys
uses: shimataro/ssh-key-action@v2
with:
name: id_ed25519
key: ${{ secrets.DEPLOY_PRIVATE_KEY }}
known_hosts: ${{ secrets.DEPLOY_KNOWN_HOSTS }}
config: |
Host bastion
HostName ${{ secrets.DEPLOY_JUMP_HOST }}
User ${{ secrets.DEPLOY_JUMP_USERNAME }}
Host learnweb
HostName ${{ secrets.DEPLOY_HOST }}
User ${{ secrets.DEPLOY_USERNAME }}
ProxyJump bastion
- name: Check if artifact exists
run: ssh learnweb test -f "${{ secrets.DEPLOY_PATH }}/ROOT##${{ needs.build.outputs.version }}.war" && exit 1
- name: Copy artifact to server
run: rsync -avzh --ignore-existing ROOT##*.war learnweb:${{ secrets.DEPLOY_PATH }}/