-
Notifications
You must be signed in to change notification settings - Fork 1
130 lines (123 loc) · 3.78 KB
/
production.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
name: "[Production] Build web app, electron app, server, and publish/deploy to production"
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
env:
CONFIG_FILE: config-prod.json
defaults:
run:
shell: bash
jobs:
setup:
name: 'Set up node and repository'
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ macos-latest, ubuntu-latest, windows-latest ]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up node / npm with caching
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: |
package-lock.json
**/package-lock.json
- name: Decrypt configuration
run: ./config/decrypt-config.sh
env:
CONFIG_DECRYPT_PASSPHRASE: ${{ secrets.CONFIG_DECRYPT_PASSPHRASE }}
- name: Install root dependencies
run: npm ci
- name: Install subpackage dependencies
run: |
packages=( "config" "common" "server" )
for dir in "${packages[@]}"
do
pushd "$dir"
npm ci
popd
done
pushd client
npm ci || echo 'Ignore return code, known errors in postinstall step'
popd
- name: Pack setup
run: tar cf setup.tar *
- name: Store setup (as artifact)
uses: actions/upload-artifact@v4
with:
name: setup-${{ matrix.os }}
retention-days: 1
path: setup.tar
build-deploy-web:
name: Build and deploy frontend
runs-on: ubuntu-latest
needs: [setup]
steps:
- name: Download setup (from artifact)
uses: actions/download-artifact@v4
with:
name: setup-ubuntu-latest
- name: Unpack setup
run: tar xf setup.tar && rm setup.tar
- name: Build frontend
run: npm run client:build:web
- name: Deploy via FTP
uses: sebastianpopp/ftp-action@releases/v2
with:
localDir: ./client/out/web/
remoteDir: ./
host: amsr102.websitehostserver.net:21
user: [email protected]
password: ${{ secrets.FTP_PASSWORD }}
build-electron:
name: Build Electron app
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ macos-latest, ubuntu-latest, windows-latest ]
needs: [setup]
steps:
- name: Download setup (from artifact)
uses: actions/download-artifact@v4
with:
name: setup-${{ matrix.os }}
- name: Unpack setup
run: tar xf setup.tar && rm setup.tar
- name: Build and publish Electron app
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npm run client:publish:electron
deploy-backend:
name: Deploy backend
runs-on: ubuntu-latest
needs: [setup]
steps:
- name: Install required packages
run: sudo apt-get install -y lftp
- name: Install SSH key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_KEY }}
known_hosts: ${{ secrets.KNOWN_HOSTS }}
- name: Download setup (from artifact)
uses: actions/download-artifact@v4
with:
name: setup-ubuntu-latest
- name: Unpack setup
run: tar xf setup.tar && rm setup.tar
- name: Pack server
run: tar cf server.tar common config server package.json
- name: Deploy
run: ./server/scripts/deploy/deploy.sh
- name: Check HTTP status code
shell: bash
run: |
sleep 30
BACKEND_URL=$(jq -r '.BACKEND_URL' "./config/$CONFIG_FILE")
RESPONSE_CODE=$(curl -sL -w "%{http_code}" -I "$BACKEND_URL/hello" -o /dev/null)
echo "HTTP response code from $BACKEND_URL/hello : $RESPONSE_CODE"
[ "$RESPONSE_CODE" == "200" ]