-
Notifications
You must be signed in to change notification settings - Fork 0
66 lines (58 loc) · 2.09 KB
/
deploy.yml
File metadata and controls
66 lines (58 loc) · 2.09 KB
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
name: Epaper Website Deploy
on:
push:
branches:
- main
- ui
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Update the repo from web server
uses: appleboy/ssh-action@v0.1.7
env:
NODE_OPTIONS: --openssl-legacy-provider
CI: false
ANALYZE: true
with:
host: ${{ secrets.WEB_SERVER_2 }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.PRIV_KEY }}
envs: CI, NODE_OPTIONS
script: |
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/github@web-server-2
export PATH=/root/.nvm/versions/node/v21.0.0/bin/:$PATH
cd ~/epaper/
git stash save --keep-index --include-untracked
git pull
if ! [ $? -eq 0 ]; then
echo "git pull failed with errors."
exit 1
fi
cp web/api/epaper-backend.service /etc/systemd/system/epaper-backend.service
cp web/ui/epaper.service /etc/systemd/system/epaper.service
systemctl stop epaper-backend.service epaper.service
systemctl daemon-reload
echo "Service files copied!"
cd web/api
npm install
if [ $? -eq 0 ]; then
systemctl restart epaper-backend.service
systemctl is-active --quiet epaper-backend.service && echo "Epaper backend server restarted successfully." || (echo "Epaper backend server failed to restart." && exit 1)
else
echo "npm install failed with error. Stopped restarting the epaper server."
exit 1
fi
cd ../ui
npm install
npm run build
if [ $? -eq 0 ]; then
systemctl restart epaper.service
systemctl is-active --quiet epaper.service && echo "Epaper UI server restarted successfully." || (echo "Epaper UI server failed to restart." && exit 1)
else
echo "npm run build failed with error. Stopped restarting the epaper server."
exit 1
fi