#!/usr/bin/env python3 """ Update GitHub Pages Files Fixes the hardcoded timestamp and ensures proper deployment. Addresses Issues #115 and #129. """ import json from datetime import datetime from pathlib import Path import re def update_html_timestamp(html_file: str): """Update the timestamp in the HTML file to current date.""" file_path = Path(html_file) if not file_path.exists(): print(f"Warning: {html_file} not found") return False # Read the HTML file with open(file_path, "r", encoding="utf-8") as f: content = f.read() # Get current month and year current_date = datetime.now().strftime("%B %Y") # Replace the hardcoded timestamp # Look for pattern like "Last updated: Month Year" pattern = r'(

404

Page not found

The n8n workflows repository has been updated.

Go to Homepage
""" error_file = Path("docs/404.html") with open(error_file, "w", encoding="utf-8") as f: f.write(error_page_content) print(f"✅ Created 404 page: {error_file}") def verify_github_pages_structure(): """Verify that all necessary files exist for GitHub Pages deployment.""" required_files = [ "docs/index.html", "docs/css/styles.css", "docs/js/app.js", "docs/js/search.js", "docs/api/search-index.json", "docs/api/stats.json", "docs/api/categories.json", "docs/api/integrations.json", ] missing_files = [] for file_path in required_files: if not Path(file_path).exists(): missing_files.append(file_path) print(f"❌ Missing: {file_path}") else: print(f"✅ Found: {file_path}") if missing_files: print(f"\n⚠️ Warning: {len(missing_files)} required files are missing") print("Run the following commands to generate them:") print(" python workflow_db.py --index --force") print(" python create_categories.py") print(" python scripts/generate_search_index.py") return False print("\n✅ All required files present for GitHub Pages deployment") return True def fix_base_url_references(): """Fix any hardcoded URLs to use relative paths for GitHub Pages.""" # Update index.html to use relative paths index_file = Path("docs/index.html") if index_file.exists(): with open(index_file, "r", encoding="utf-8") as f: content = f.read() # Replace absolute paths with relative ones replacements = [ ('href="/css/', 'href="css/'), ('src="/js/', 'src="js/'), ('href="/api/', 'href="api/'), ('fetch("/api/', 'fetch("api/'), ("fetch('/api/", "fetch('api/"), ] for old, new in replacements: content = content.replace(old, new) with open(index_file, "w", encoding="utf-8") as f: f.write(content) print("✅ Fixed URL references in index.html") # Update JavaScript files js_files = ["docs/js/app.js", "docs/js/search.js"] for js_file in js_files: js_path = Path(js_file) if js_path.exists(): with open(js_path, "r", encoding="utf-8") as f: content = f.read() # Fix API endpoint references content = content.replace("fetch('/api/", "fetch('api/") content = content.replace('fetch("/api/', 'fetch("api/') content = content.replace("'/api/", "'api/") content = content.replace('"/api/', '"api/') with open(js_path, "w", encoding="utf-8") as f: f.write(content) print(f"✅ Fixed URL references in {js_file}") def main(): """Main function to update GitHub Pages deployment.""" print("🔧 GitHub Pages Update Script") print("=" * 50) # Step 1: Update timestamps print("\n📅 Updating timestamps...") update_html_timestamp("docs/index.html") update_api_timestamp("docs/api") # Step 2: Create GitHub Pages configuration print("\n⚙️ Creating GitHub Pages configuration...") create_github_pages_config() # Step 3: Fix URL references print("\n🔗 Fixing URL references...") fix_base_url_references() # Step 4: Verify structure print("\n✔️ Verifying deployment structure...") if verify_github_pages_structure(): print("\n✨ GitHub Pages setup complete!") print("\nDeployment will be available at:") print(" https://zie619.github.io/n8n-workflows/") print( "\nNote: It may take a few minutes for changes to appear after pushing to GitHub." ) else: print("\n⚠️ Some files are missing. Please generate them first.") if __name__ == "__main__": main()