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:
|
|
|
|
|
- name: Checkout
|
2026-04-30 13:54:16 +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: |
|
|
|
|
|
mkdir -p ~/.ssh
|
|
|
|
|
echo "${{ secrets.NAS_SSH_KEY }}" > ~/.ssh/id_deploy
|
|
|
|
|
chmod 600 ~/.ssh/id_deploy
|
|
|
|
|
cat >> ~/.ssh/config << 'EOF'
|
|
|
|
|
Host nas
|
|
|
|
|
HostName 192.168.1.208
|
|
|
|
|
User Elewyn
|
|
|
|
|
IdentityFile ~/.ssh/id_deploy
|
|
|
|
|
StrictHostKeyChecking no
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
|
|
- name: Sync files to NAS
|
|
|
|
|
run: |
|
|
|
|
|
rsync -av --delete \
|
|
|
|
|
--exclude='.git' \
|
|
|
|
|
--exclude='.env' \
|
|
|
|
|
--exclude='data/' \
|
|
|
|
|
--exclude='screenshots/' \
|
|
|
|
|
--exclude='logs/' \
|
|
|
|
|
./ nas:${{ env.DEPLOY_PATH }}/
|
|
|
|
|
|
|
|
|
|
- name: Restart bot on NAS
|
|
|
|
|
run: |
|
|
|
|
|
ssh nas "cd ${{ env.DEPLOY_PATH }} && \
|
|
|
|
|
docker compose down || true && \
|
|
|
|
|
docker compose up --build -d"
|