commit 030a27671d2f6c841b79c1d68149fdab04dc30a0
parent 6c57348ecc4c9f70cab434671a5987110ec5c481
Author: _listen-bot <_listen-bot@chappelle.dev>
Date: Thu, 5 Feb 2026 16:27:10 -0800
bot commit: add deploy step
Diffstat:
1 file changed, 22 insertions(+), 0 deletions(-)
diff --git a/listen-page-bot/bot.py b/listen-page-bot/bot.py
@@ -1,4 +1,5 @@
import os
+import subprocess
import requests
import frontmatter
from bs4 import BeautifulSoup
@@ -58,6 +59,8 @@ async def get_cover(update: Update, context: ContextTypes.DEFAULT_TYPE):
img_url=f"/assets/covers/{img_filename}" # Relative path for HTML
)
+ run_local_deploy(REPO_PATH)
+
await update.message.reply_text("Successfully updated listen.md and saved cover!")
return ConversationHandler.END
@@ -102,6 +105,25 @@ def update_markdown(title, artist, link, img_url):
with open(MD_FILE_PATH, 'wb') as f:
frontmatter.dump(post, f)
+def run_local_deploy(repo_path):
+ try:
+ # 1. Git Add & Commit
+ subprocess.run(["git", "add", "."], cwd=repo_path, check=True)
+ subprocess.run(["git", "commit", "-m", "Bot: auto-update listen.md"], cwd=repo_path, check=True)
+
+ # 2. Git Push
+ # (Works instantly if remote is a local path or SSH key has no passphrase)
+ subprocess.run(["git", "push"], cwd=repo_path, check=True)
+
+ # 3. Make Deploy
+ # This calls the Makefile which uses 'doas rsync'
+ subprocess.run(["make", "deploy"], cwd=repo_path, check=True)
+
+ return True
+ except subprocess.CalledProcessError as e:
+ print(f"Deployment failed at: {e.cmd}")
+ return False
+
async def cancel(update: Update, context: ContextTypes.DEFAULT_TYPE):
await update.message.reply_text("Cancelled.")
return ConversationHandler.END