telegrambot/.gitea/workflows/deploy.yml
alisaza a541075765
Some checks failed
CI / Typecheck and test (push) Failing after 1m36s
Deploy / Typecheck and test (push) Failing after 35s
Deploy / Deploy to VPS (push) Has been skipped
Add Gitea Actions CI/CD and production deploy scripts.
Wire typecheck/test on PR/push and SSH deploy to the foreign VPS on main.
2026-09-13 14:39:59 +03:30

68 lines
1.9 KiB
YAML

name: Deploy
on:
push:
branches: [main]
workflow_dispatch:
concurrency:
group: deploy-telegram-relay
cancel-in-progress: true
jobs:
test:
name: Typecheck and test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: npm
- run: npm ci
- run: npm run typecheck
- run: npm test
deploy:
name: Deploy to VPS
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Deploy over SSH
env:
SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
VPS_HOST: ${{ secrets.VPS_HOST }}
VPS_USER: ${{ secrets.VPS_USER }}
run: |
set -euo pipefail
test -n "${SSH_KEY:-}"
test -n "${VPS_HOST:-}"
test -n "${VPS_USER:-}"
sudo apt-get update -qq
sudo apt-get install -y -qq rsync openssh-client
install -m 700 -d "$HOME/.ssh"
printf '%s\n' "$SSH_KEY" > "$HOME/.ssh/deploy_key"
chmod 600 "$HOME/.ssh/deploy_key"
SSH=(ssh -i "$HOME/.ssh/deploy_key" -o IdentitiesOnly=yes -o StrictHostKeyChecking=accept-new)
"${SSH[@]}" "${VPS_USER}@${VPS_HOST}" 'install -d -m 0750 /opt/ghabilee-telegram-relay'
rsync -az --delete \
-e "ssh -i $HOME/.ssh/deploy_key -o IdentitiesOnly=yes -o StrictHostKeyChecking=accept-new" \
--exclude '.git' \
--exclude 'node_modules' \
--exclude 'dist' \
--exclude '.env' \
./ "${VPS_USER}@${VPS_HOST}:/opt/ghabilee-telegram-relay/"
"${SSH[@]}" "${VPS_USER}@${VPS_HOST}" \
'chmod +x /opt/ghabilee-telegram-relay/scripts/deploy-on-vps.sh && APP_DIR=/opt/ghabilee-telegram-relay /opt/ghabilee-telegram-relay/scripts/deploy-on-vps.sh'
rm -f "$HOME/.ssh/deploy_key"