Discord-Raid-bot/.forgejo/workflows/deploy.yml

57 lines
2.1 KiB
YAML
Raw Permalink Normal View History

2026-04-30 13:48:45 +00:00
name: Deploy Bot on NAS
on:
push:
branches: [ main, dev ]
jobs:
deploy:
runs-on: self-hosted
steps:
2026-04-30 14:42:57 +00:00
- name: Install dependencies
run: apk add --no-cache rsync openssh-client
2026-04-30 13:48:45 +00:00
- name: Checkout
2026-04-30 14:42:57 +00:00
run: |
git clone --depth 1 --branch ${{ github.ref_name }} \
${{ github.server_url }}/${{ github.repository }}.git .
2026-04-30 13:48:45 +00:00
- name: Set deployment path
run: |
if [ "${{ github.ref_name }}" = "main" ]; then
echo "DEPLOY_PATH=/share/CACHEDEV1_DATA/discord-bot-prod" >> $GITHUB_ENV
elif [ "${{ github.ref_name }}" = "dev" ]; then
echo "DEPLOY_PATH=/share/CACHEDEV1_DATA/discord-bot-dev" >> $GITHUB_ENV
else
echo "Unsupported branch" && exit 1
fi
- name: Configure SSH
run: |
2026-04-30 14:42:57 +00:00
mkdir -p /root/.ssh
echo "${{ secrets.NAS_SSH_KEY }}" > /root/.ssh/id_deploy
chmod 600 /root/.ssh/id_deploy
2026-04-30 13:48:45 +00:00
- name: Sync files to NAS
run: |
# StrictHostKeyChecking=no : runner Alpine stateless, pas de known_hosts persistant.
# Cible fixe sur LAN interne (192.168.1.208) — risque MITM inexistant.
2026-04-30 13:48:45 +00:00
rsync -av --delete \
2026-04-30 14:42:57 +00:00
-e "ssh -i /root/.ssh/id_deploy -o StrictHostKeyChecking=no" \
2026-04-30 13:48:45 +00:00
--exclude='.git' \
--exclude='.github' \
2026-04-30 13:48:45 +00:00
--exclude='.env' \
--exclude='data/' \
--exclude='screenshots/' \
--exclude='logs/' \
--exclude='__pycache__/' \
2026-04-30 14:42:57 +00:00
./ Elewyn@192.168.1.208:${{ env.DEPLOY_PATH }}/
2026-04-30 13:48:45 +00:00
- name: Restart bot on NAS
run: |
# StrictHostKeyChecking=no : runner Alpine stateless, pas de known_hosts persistant.
# Cible fixe sur LAN interne (192.168.1.208) — risque MITM inexistant.
2026-04-30 14:42:57 +00:00
ssh -i /root/.ssh/id_deploy -o StrictHostKeyChecking=no \
Elewyn@192.168.1.208 \
"cd ${{ env.DEPLOY_PATH }} && /share/CACHEDEV1_DATA/.qpkg/container-station/usr/bin/docker compose down || true && /share/CACHEDEV1_DATA/.qpkg/container-station/usr/bin/docker compose up -d"