-
Notifications
You must be signed in to change notification settings - Fork 1
47 lines (37 loc) · 1.24 KB
/
deploy.yml
File metadata and controls
47 lines (37 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
name: Build, Test and Deploy Discord Bot to VPS
on:
push:
branches: [ "main" ]
workflow_dispatch: # Allow manual deployment
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Deploy to VPS
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.VPS_HOST }}
username: ${{ secrets.VPS_USER }}
key: ${{ secrets.VPS_SSH_KEY }}
script: |
cd /home/${{ secrets.VPS_USER }}/webdev-bot
# Stash any local changes
git stash push -m "Auto-deploy $(date)" 2>/dev/null || true
# Pull latest changes
git checkout main
git pull origin main
# Create .env.local file with secrets
cat > .env.local << EOF
DISCORD_TOKEN=${{ secrets.DISCORD_TOKEN }}
CLIENT_ID=${{ secrets.CLIENT_ID }}
NODE_VERSION=$(cat .nvmrc | tr -d 'v')
EOF
# Stop any existing containers
docker-compose down || true
# Build and start production container with profile
docker-compose --profile prod up -d --build
# Check status
echo "Deployment completed. Container status:"
docker-compose ps