From 13b2315ebfc72a693ec1ede10604dd7589ff60dd Mon Sep 17 00:00:00 2001 From: Jared Vititoe Date: Tue, 13 Jan 2026 15:38:45 -0500 Subject: [PATCH] Add deployment scripts and webhook configuration --- deployment/discord_bot_deploy.sh | 57 ++++++++++++++++++++++++++++++++ deployment/hooks.json | 18 ++++++++++ 2 files changed, 75 insertions(+) create mode 100644 deployment/discord_bot_deploy.sh create mode 100644 deployment/hooks.json diff --git a/deployment/discord_bot_deploy.sh b/deployment/discord_bot_deploy.sh new file mode 100644 index 0000000..1c53193 --- /dev/null +++ b/deployment/discord_bot_deploy.sh @@ -0,0 +1,57 @@ +#!/bin/bash +set -e + +BOTDIR="/root/code/discordBot" +SERVICE_NAME="discord-bot" + +echo "[Discord Bot] Pulling latest code..." + +# Backup .env if it exists +if [ -f "$BOTDIR/.env" ]; then + cp "$BOTDIR/.env" /tmp/.env.backup +fi + +# Backup media and logs folders +if [ -d "$BOTDIR/media" ]; then + cp -r "$BOTDIR/media" /tmp/media.backup +fi +if [ -d "$BOTDIR/logs" ]; then + cp -r "$BOTDIR/logs" /tmp/logs.backup +fi + +if [ ! -d "$BOTDIR/.git" ]; then + echo "Directory not a git repo — performing initial clone..." + rm -rf "$BOTDIR" + git clone https://code.lotusguild.org/LotusGuild/discordBot.git "$BOTDIR" +else + echo "Updating existing repo..." + cd "$BOTDIR" + git fetch --all + git reset --hard origin/main +fi + +# Restore .env if it was backed up +if [ -f /tmp/.env.backup ]; then + mv /tmp/.env.backup "$BOTDIR/.env" +fi + +# Restore media and logs folders +if [ -d /tmp/media.backup ]; then + rm -rf "$BOTDIR/media" + mv /tmp/media.backup "$BOTDIR/media" +fi +if [ -d /tmp/logs.backup ]; then + rm -rf "$BOTDIR/logs" + mv /tmp/logs.backup "$BOTDIR/logs" +fi + +echo "[Discord Bot] Installing/updating dependencies..." +cd "$BOTDIR" +pip3 install -r requirements.txt 2>/dev/null || echo "No requirements.txt found, skipping..." + +echo "[Discord Bot] Restarting service..." +systemctl restart "$SERVICE_NAME" + +echo "[Discord Bot] Deployment complete!" +echo "[Discord Bot] Service status:" +systemctl status "$SERVICE_NAME" --no-pager diff --git a/deployment/hooks.json b/deployment/hooks.json new file mode 100644 index 0000000..91389cb --- /dev/null +++ b/deployment/hooks.json @@ -0,0 +1,18 @@ +[ + { + "id": "discord-bot-deploy", + "execute-command": "/usr/local/bin/discord_bot_deploy.sh", + "command-working-directory": "/root/code/discordBot", + "response-message": "Deploying Discord bot...", + "trigger-rule": { + "match": { + "type": "payload-hash-sha256", + "secret": "CHANGE_THIS_SECRET_KEY", + "parameter": { + "source": "header", + "name": "X-Gitea-Signature" + } + } + } + } +]