From a9eec7c9a346d12252ac91492b3e939f9c789a2a Mon Sep 17 00:00:00 2001 From: Ali Hammoud Date: Thu, 6 Nov 2025 02:59:08 +0200 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=A4=96=20ci:=20add=20GitHub=20Actions?= =?UTF-8?q?=20workflow=20for=20deploying=20Discord=20commands=20to=20VPS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy-commands.yml | 29 +++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .github/workflows/deploy-commands.yml diff --git a/.github/workflows/deploy-commands.yml b/.github/workflows/deploy-commands.yml new file mode 100644 index 0000000..88a5d2a --- /dev/null +++ b/.github/workflows/deploy-commands.yml @@ -0,0 +1,29 @@ +name: Deploy Discord Commands + +on: + workflow_dispatch: # Manual trigger only + +jobs: + deploy-commands: + runs-on: ubuntu-latest + + steps: + - name: Deploy Discord Commands 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-deploy + + # Set up environment variables for the deploy script + export DISCORD_TOKEN="${{ secrets.DISCORD_TOKEN }}" + export CLIENT_ID="${{ secrets.CLIENT_ID }}" + export NODE_ENV=production + + # Run the deploy script + echo "Deploying Discord commands..." + node dist/util/deploy.js + + echo "Discord commands deployment completed!" \ No newline at end of file From 2d6d5ddec108f2122eb6ee3d4562f939dd98237b Mon Sep 17 00:00:00 2001 From: Ali Hammoud Date: Thu, 6 Nov 2025 03:07:39 +0200 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=90=9B=20fix:=20update=20deploy=20com?= =?UTF-8?q?mands=20script=20to=20load=20environment=20variables=20from=20.?= =?UTF-8?q?env=20files?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy-commands.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/deploy-commands.yml b/.github/workflows/deploy-commands.yml index 88a5d2a..4dfb2ae 100644 --- a/.github/workflows/deploy-commands.yml +++ b/.github/workflows/deploy-commands.yml @@ -17,9 +17,9 @@ jobs: script: | cd /home/${{ secrets.VPS_USER }}/webdev-bot-deploy - # Set up environment variables for the deploy script - export DISCORD_TOKEN="${{ secrets.DISCORD_TOKEN }}" - export CLIENT_ID="${{ secrets.CLIENT_ID }}" + # Load environment variables + source .env + source .env.production export NODE_ENV=production # Run the deploy script From ec10f20b16a4562539a411537ec5d71e6ca735b7 Mon Sep 17 00:00:00 2001 From: Ali Hammoud Date: Thu, 6 Nov 2025 12:21:58 +0200 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=A4=96=20ci:=20run=20deploy=20command?= =?UTF-8?q?=20in=20existing=20container=20using=20`docker=20compose`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy-commands.yml | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/.github/workflows/deploy-commands.yml b/.github/workflows/deploy-commands.yml index 4dfb2ae..fd1d558 100644 --- a/.github/workflows/deploy-commands.yml +++ b/.github/workflows/deploy-commands.yml @@ -8,6 +8,14 @@ jobs: 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 Discord Commands to VPS uses: appleboy/ssh-action@v1.0.3 with: @@ -16,14 +24,14 @@ jobs: key: ${{ secrets.VPS_SSH_KEY }} script: | cd /home/${{ secrets.VPS_USER }}/webdev-bot-deploy - - # Load environment variables - source .env - source .env.production - export NODE_ENV=production - - # Run the deploy script + + # Read NODE_VERSION from .nvmrc + export NODE_VERSION=$(cat .nvmrc | sed 's/v//') + echo "Using Node version: $NODE_VERSION" + + # Run deploy script inside the already running Docker container + # .env file should already exist from main deployment echo "Deploying Discord commands..." - node dist/util/deploy.js - + docker compose --profile prod exec bot-prod node dist/util/deploy.js + echo "Discord commands deployment completed!" \ No newline at end of file