-
Notifications
You must be signed in to change notification settings - Fork 4
63 lines (60 loc) · 2.69 KB
/
toolforge-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
name: Toolforge
on:
push:
branches:
- master
workflow_dispatch:
concurrency:
group: tf-deploy
cancel-in-progress: true
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: appleboy/ssh-action@551964ebda1034f0b5449d74db25c42e371ca1f7
with:
script: >-
become sdzerobot bash -c '
set -eo pipefail;
cd /data/project/sdzerobot/mwn;
if [[ "$(git pull --ff-only | grep -c "Already up to date")" -eq 0 ]]; then
if [[ "$(git diff --name-only HEAD HEAD@{1} | grep -c package.json)" -gt 0 ]]; then
echo "Running npm install for mwn ...";
npm install;
fi;
echo "Building mwn ...";
npm run build;
fi;
cd /data/project/sdzerobot/SDZeroBot;
echo "Pulling SDZeroBot ...";
git checkout master;
git pull --ff-only;
if [[ "$(git diff --name-only HEAD HEAD@{1} | grep -c package.json)" -gt 0 ]]; then
echo "Running npm install for SDZeroBot ...";
npm install;
fi;
echo "Building SDZeroBot ...";
npm run tsc;
if [[ "$(git diff --name-only HEAD HEAD@{1} | grep -c crontab)" -gt 0 ]]; then
echo "Updating the crontab ...";
crontab crontab;
fi;
if [[ "$(git diff --name-only HEAD HEAD@{1} | grep -c jobs.yml)" -gt 0 ]]; then
echo "Updating jobs.yml ...";
toolforge jobs load jobs.yml;
fi;
if [[ "$(git diff --name-only HEAD HEAD@{1} | grep -c eventstream)" -gt 0 || "$(git rev-list --format=%B --max-count=1 HEAD)" == *"!restart"* ]]; then
echo "Restarting eventstream-router ...";
cd eventstream-router && npm restart && cd -;
fi;
cp webservice/www-js-package.json /data/project/sdzerobot/www/js/package.json;
if [[ "$(git diff --name-only HEAD HEAD@{1} | grep -c "webservice/")" -gt 0 || "$(git diff --name-only HEAD HEAD@{1} | grep -c "web-endpoint")" -gt 0 || "$(git diff --name-only HEAD HEAD@{1} | grep -c "hbs")" -gt 0 || "$(git rev-list --format=%B --max-count=1 HEAD)" == *"!restart"* || "$(git rev-list --format=%B --max-count=1 HEAD)" == *"!web-restart"* ]]; then
echo "Restarting SDZeroBot webservice ...";
cd /data/project/sdzerobot/SDZeroBot/webservice;
npm restart;
fi;
'
host: login.toolforge.org
username: sd
key: ${{ secrets.TOOLFORGE_PRIVATE_KEY }}