From 1184ff9060cf5da595433c45176b5be703c58af9 Mon Sep 17 00:00:00 2001 From: "AB from home.homenet" Date: Tue, 16 Sep 2025 16:01:41 +0300 Subject: [PATCH] Added wiki generator --- .gitea/scripts/generate-apps-wiki.py | 41 ++++++++++++++++++++-------- .gitea/workflows/update-wiki.yml | 15 +++++++++- 2 files changed, 44 insertions(+), 12 deletions(-) diff --git a/.gitea/scripts/generate-apps-wiki.py b/.gitea/scripts/generate-apps-wiki.py index 5e55609..51ddfb0 100644 --- a/.gitea/scripts/generate-apps-wiki.py +++ b/.gitea/scripts/generate-apps-wiki.py @@ -108,20 +108,45 @@ def main(): output_file = sys.argv[1] try: - with open(output_file, 'r') as f: - terraform_output = json.load(f) + # Check if file exists and has content + if not os.path.exists(output_file): + print(f"ERROR: File {output_file} not found") + sys.exit(1) + + file_size = os.path.getsize(output_file) + if file_size == 0: + print(f"ERROR: File {output_file} is empty") + sys.exit(1) - # Извлекаем данные приложений + print(f"📄 Reading Terraform output file: {output_file} ({file_size} bytes)") + + # Read and show first few chars for debugging + with open(output_file, 'r') as f: + content = f.read() + print(f"🔍 File content preview: {content[:100]}...") + + # Parse JSON + try: + terraform_output = json.loads(content) + except json.JSONDecodeError as e: + print(f"ERROR: Invalid JSON in {output_file}: {e}") + print(f"Content starts with: {content[:50]}") + sys.exit(1) + + # Extract application data apps_data = terraform_output.get('applications_for_wiki', {}).get('value', {}) if not apps_data: print("ERROR: No applications_for_wiki output found in Terraform output") + print(f"Available outputs: {list(terraform_output.keys())}") sys.exit(1) - # Генерируем Markdown + print(f"📊 Found {len(apps_data.get('proxy_apps', {}))} proxy apps, {len(apps_data.get('oauth_apps', {}))} oauth apps") + + # Generate Markdown markdown_content = generate_markdown_table(apps_data) - # Записываем результат + # Write result wiki_file = "Applications.md" with open(wiki_file, 'w', encoding='utf-8') as f: f.write(markdown_content) @@ -129,12 +154,6 @@ def main(): print(f"✅ Wiki page generated: {wiki_file}") print(f"📊 Total applications: {len(apps_data.get('proxy_apps', {})) + len(apps_data.get('oauth_apps', {}))}") - except FileNotFoundError: - print(f"ERROR: File {output_file} not found") - sys.exit(1) - except json.JSONDecodeError as e: - print(f"ERROR: Invalid JSON in {output_file}: {e}") - sys.exit(1) except Exception as e: print(f"ERROR: {e}") sys.exit(1) diff --git a/.gitea/workflows/update-wiki.yml b/.gitea/workflows/update-wiki.yml index 56c5c20..15650a6 100644 --- a/.gitea/workflows/update-wiki.yml +++ b/.gitea/workflows/update-wiki.yml @@ -35,12 +35,25 @@ jobs: - name: Generate Terraform Output run: | + echo "🔍 Generating Terraform output..." terraform output -json > terraform-output.json + + # Debug output file + echo "📄 Output file size: $(wc -c < terraform-output.json) bytes" + echo "🔍 First 200 chars of output:" + head -c 200 terraform-output.json + echo "" echo "✅ Terraform output generated" - name: Generate Wiki Content run: | - cat terraform-output.json + echo "🔍 Checking output file..." + if [ ! -f "terraform-output.json" ]; then + echo "❌ terraform-output.json not found" + exit 1 + fi + + echo "📊 Running wiki generation script..." python3 ../../.gitea/scripts/generate-apps-wiki.py terraform-output.json echo "✅ Wiki content generated"