Skip to content

most-gans: minor optimisation, logger update #129

most-gans: minor optimisation, logger update

most-gans: minor optimisation, logger update #129

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;
if [[ "$(git diff --name-only HEAD HEAD@{1} | grep -c "webservice/")" -gt 0 ]]; then
if [[ "$(git diff --name-only HEAD HEAD@{1} | grep -c "webservice/package.json")" -gt 0 ]]; then
echo "Running npm install for SDZeroBot/webservice ...";
cd /data/project/sdzerobot/SDZeroBot/webservice && npm install --only=production;
fi;
echo "Syncing SDZeroBot/webservice with www/js ...";
cd /data/project/sdzerobot && rsync -avu --delete "SDZeroBot/webservice/" "www/js";
echo "Restarting SDZeroBot webservice ...";
cd /data/project/sdzerobot/www/js;
if [[ ($(grep "\.\." *.ts | grep -v SDZeroBot | grep -v -c mwn) -gt 0) || ($(grep "\.\.\/\.\." routes/*.ts | grep -v SDZeroBot | grep -v -c mwn) -gt 0) ]]; then
echo "Suspicious imports found in webservice!";
grep "\.\." *.ts | grep -v SDZeroBot;
grep "\.\.\/\.\." routes/*.ts | grep -v SDZeroBot;
exit 1;
fi;
npm restart;
elif [[ "$(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/www/js && npm restart;
fi;
'
host: login.toolforge.org
username: sd
key: ${{ secrets.TOOLFORGE_PRIVATE_KEY }}