feat: command registration (#43) #61
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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: Read Node version | |
| run: | | |
| NODE_VERSION=$(cat .nvmrc | sed 's/v//') | |
| echo "NODE_VERSION=$NODE_VERSION" >> $GITHUB_ENV | |
| - name: Deploy to VPS | |
| uses: appleboy/[email protected] | |
| with: | |
| host: ${{ secrets.VPS_HOST }} | |
| username: ${{ secrets.VPS_USER }} | |
| key: ${{ secrets.VPS_SSH_KEY }} | |
| script: | | |
| cd /home/${{ secrets.VPS_USER }}/webdev-bot-deploy | |
| # 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 | |
| # Read NODE_VERSION from .nvmrc | |
| export NODE_VERSION=$(cat .nvmrc | sed 's/v//') | |
| echo "Using Node version: $NODE_VERSION" | |
| # Create .env file with secrets | |
| # Public config comes from .env.production (committed to repo) | |
| # NODE_ENV=production is set in docker-compose.yml | |
| cat > .env << EOF | |
| DISCORD_TOKEN=${{ secrets.DISCORD_TOKEN }} | |
| CLIENT_ID=${{ secrets.CLIENT_ID }} | |
| EOF | |
| # Stop any existing containers | |
| docker compose down || true | |
| # Build and start production container with profile | |
| # NODE_ENV=production is explicitly set in docker-compose.yml bot-prod service | |
| docker compose --profile prod up -d --build | |
| # Check status | |
| echo "Deployment completed. Container status:" | |
| docker compose ps |