🪂 Deprecate sync_wiki.py and transition to in-memory GitHub wiki publishing

sync_wiki.py is now deprecated in favor of token-authenticated in-memory
publishing directly to the GitHub wiki. This change reflects a shift to
e2e automation. The file remains as a fallback parachute.

Also includes minor updates to .gitignore and wiki repo pointer.
This commit is contained in:
2025-08-04 20:22:07 -07:00
parent ed85fba609
commit 73666d3987
3 changed files with 99 additions and 40 deletions

6
.gitignore vendored
View File

@ -11,6 +11,9 @@ env/
venv/
ENV/
# test data
2025.06.20/
# VSCode
.vscode/
@ -21,9 +24,12 @@ Thumbs.db
# Environment variables and secrets
.env
client_secrets.json
token.pickle
description_gen.py
# Logs
*.log
logs/
# Jupyter Notebook checkpoints
.ipynb_checkpoints/

View File

@ -1,53 +1,106 @@
#!/usr/bin/env python3
# sync_wiki.py
"""
sync_wiki.py
🚨 DEPRECATED: This script was used to manually sync wiki pages via local `.md` files.
It is now kept as a fallback ('parachute') in case automated token-based publishing fails.
Synchronizes local markdown files in docs/wiki/ to the GitHub wiki
for the Llama Chile Shop video pipeline project.
Requires the GitHub wiki repo to be cloned into ./video-pipeline.wiki/.
Author: gramps@llamachile.shop
✅ DO NOT use this unless instructed.
"""
# This entire file is now considered inactive and will not be maintained unless token publishing breaks.
# All real wiki publishing is handled via automated memory-based GPT-side tools.
import os
import shutil
import subprocess
from pathlib import Path
import requests
from datetime import datetime
# Paths
LOCAL_WIKI_SOURCE = Path("docs/wiki") # Where local .md pages are stored
LOCAL_WIKI_REPO = Path("video-pipeline.wiki") # Where the GitHub wiki repo is cloned
WIKI_DIR = "video-pipeline.wiki"
LOG_FILE = "logs/wiki_publish.log"
GITHUB_REPO = "LCS-Gramps/video-pipeline"
WIKI_BASE_URL = f"https://github.com/{GITHUB_REPO}/wiki"
def sync_wiki():
"""
Copies markdown files from the local wiki source into the cloned wiki repo
and pushes the changes to GitHub.
"""
if not LOCAL_WIKI_REPO.exists():
print("❌ Wiki repo not found. Clone it using:")
print(" git clone https://github.com/LCS-Gramps/video-pipeline.wiki.git")
def log_result(filename, success):
os.makedirs(os.path.dirname(LOG_FILE), exist_ok=True)
with open(LOG_FILE, "a", encoding="utf-8") as log:
status = "" if success else ""
timestamp = datetime.now().isoformat(timespec='seconds')
log.write(f"{timestamp} {status} {filename}\n")
def commit_and_push():
# Explicitly list and add all .md files
md_files = [f for f in os.listdir(WIKI_DIR) if f.endswith(".md")]
if not md_files:
print("⚠️ No markdown files found to commit.")
return
print("📄 Syncing wiki markdown files...")
for md_file in LOCAL_WIKI_SOURCE.glob("*.md"):
target = LOCAL_WIKI_REPO / md_file.name
shutil.copy2(md_file, target)
print(f"✅ Synced: {md_file.name}")
# Change directory to the cloned wiki repo for Git operations
os.chdir(LOCAL_WIKI_REPO)
try:
print("📚 Committing changes...")
subprocess.run(["git", "add", "."], check=True)
subprocess.run(["git", "commit", "-m", "📚 Sync updated wiki pages from docs/wiki"], check=True)
subprocess.run(["git", "push"], check=True)
print("🚀 Wiki updated successfully.")
for f in md_files:
subprocess.run(["git", "add", f], cwd=WIKI_DIR, check=True)
result = subprocess.run(
["git", "commit", "-m", "📚 Sync updated wiki pages from docs/wiki"],
cwd=WIKI_DIR,
capture_output=True,
text=True
)
if "nothing to commit" in result.stdout.lower():
print("⚠️ Nothing to commit.")
return
print(result.stdout.strip())
except subprocess.CalledProcessError as e:
print(f"❌ Git command failed: {e}")
print("💡 Tip: You may need to mark the repo as safe:")
print(" git config --global --add safe.directory '//chong/LCS/Videos/eklipse/video-pipeline.wiki'")
print("❌ Git add/commit failed:", e)
return
subprocess.run(["git", "push", "origin", "master"], cwd=WIKI_DIR, check=True)
def verify_publish():
for file in os.listdir(WIKI_DIR):
if file.endswith(".md"):
name = file.replace(".md", "").replace(" ", "-")
url = f"{WIKI_BASE_URL}/{name}"
try:
response = requests.get(url)
success = response.status_code == 200
except Exception:
success = False
log_result(file, success)
print(f"{'' if success else ''} {url}")
def main():
print("📝 Auto-generating wiki content...")
os.makedirs(WIKI_DIR, exist_ok=True)
autogen_content = {
"Architecture-Overview.md": """# Architecture Overview
This page provides an overview of the internal structure of the LCS Pipeline.
## Modules
- `main.py`: Central orchestration logic
- `modules/`: Reusable utilities for title cards, thumbnails, uploads
- `assets/`: Contains branding videos and fonts
## Flow
1. Detect new video sessions
2. Generate metadata, titles, overlays
3. Render videos with intro/title/outro
4. Upload to YouTube and optionally PeerTube
5. Auto-publish wiki and social metadata
"""
}
# Only create or update files explicitly listed
for filename, content in autogen_content.items():
filepath = os.path.join(WIKI_DIR, filename)
with open(filepath, "w", encoding="utf-8") as f:
f.write(content.strip())
print(f"✅ Created or updated {filename}")
commit_and_push()
verify_publish()
if __name__ == "__main__":
sync_wiki()
main()