admin/.gitea/workflows/deploy-vps.yml
alisaza 45db367588
Some checks failed
Deploy admin to VPS / Rsync and deploy admin (push) Failing after 10s
ci: deploy admin by building on the VPS
act_runner job images have no Docker daemon, so rsync sources and build
with scripts/deploy-on-vps.sh on the target host instead of GHCR/buildx.
2026-09-13 15:42:58 +03:30

78 lines
2.6 KiB
YAML

name: Deploy admin to VPS
# act_runner job containers have no Docker daemon. Build on the VPS (same
# pattern as telegrambot) after rsyncing sources.
on:
push:
branches: [main]
workflow_dispatch:
concurrency:
group: deploy-admin-production
cancel-in-progress: true
jobs:
deploy:
name: Rsync and deploy admin
runs-on: ubuntu-latest
timeout-minutes: 90
steps:
- uses: actions/checkout@v4
- name: Deploy over SSH
env:
SSH_KEY: ${{ secrets.VPS_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:-}"
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}" '
set -eu
install -d -m 0750 /opt/ghabilee-admin /opt/ghabilee-admin/src
test -s /opt/ghabilee-admin/.env
'
rsync -az --delete \
-e "ssh -i $HOME/.ssh/deploy_key -o IdentitiesOnly=yes -o StrictHostKeyChecking=accept-new" \
--exclude '.git' \
--exclude 'node_modules' \
--exclude '.next' \
--exclude '.env' \
--exclude '.env.*' \
--exclude 'test-results' \
--exclude 'playwright-report' \
./ "${VPS_USER}@${VPS_HOST}:/opt/ghabilee-admin/src/"
"${SSH[@]}" "${VPS_USER}@${VPS_HOST}" \
'chmod +x /opt/ghabilee-admin/src/scripts/deploy-on-vps.sh && APP_DIR=/opt/ghabilee-admin SRC_DIR=/opt/ghabilee-admin/src /opt/ghabilee-admin/src/scripts/deploy-on-vps.sh'
rm -f "$HOME/.ssh/deploy_key"
- name: Notify Telegram
if: always()
env:
DEPLOY_SHA: ${{ github.sha }}
DEPLOY_STATUS: ${{ job.status }}
DEPLOY_COMMIT_SUBJECT: ${{ github.event.head_commit.message }}
SSH_KEY: ${{ secrets.VPS_SSH_KEY }}
VPS_HOST: ${{ secrets.VPS_HOST }}
VPS_USER: ${{ secrets.VPS_USER }}
run: |
export DEPLOY_VERSION="$(node -p "require('./package.json').version" 2>/dev/null || echo '?')"
case "${DEPLOY_STATUS}" in
success) export DEPLOY_STATUS=success ;;
*) export DEPLOY_STATUS=failed ;;
esac
chmod +x scripts/notify-via-vps.sh scripts/notify-ops-telegram.sh scripts/notify-deploy.sh || true
./scripts/notify-via-vps.sh || true