diff --git a/.gitea/scripts/generate-apps-wiki.py b/.gitea/scripts/generate-apps-wiki.py index 51ddfb0..313bb17 100644 --- a/.gitea/scripts/generate-apps-wiki.py +++ b/.gitea/scripts/generate-apps-wiki.py @@ -125,6 +125,17 @@ def main(): content = f.read() print(f"🔍 File content preview: {content[:100]}...") + # Clean content - remove command line if present + if content.startswith('[command]'): + print("⚠️ Detected command prefix, removing...") + lines = content.split('\n', 1) + if len(lines) > 1: + content = lines[1] + print(f"🔍 Cleaned content preview: {content[:100]}...") + else: + print("ERROR: File contains only command line, no JSON data") + sys.exit(1) + # Parse JSON try: terraform_output = json.loads(content) @@ -133,12 +144,18 @@ def main(): print(f"Content starts with: {content[:50]}") sys.exit(1) - # Extract application data - apps_data = terraform_output.get('applications_for_wiki', {}).get('value', {}) + # Extract application data - now terraform_output IS the value + apps_data = terraform_output if not apps_data: - print("ERROR: No applications_for_wiki output found in Terraform output") - print(f"Available outputs: {list(terraform_output.keys())}") + print("ERROR: No applications data found in Terraform output") + print(f"Output content: {terraform_output}") + sys.exit(1) + + # Check if we have correct structure + if 'proxy_apps' not in apps_data and 'oauth_apps' not in apps_data: + print("ERROR: Expected 'proxy_apps' or 'oauth_apps' in output") + print(f"Available keys: {list(apps_data.keys())}") sys.exit(1) print(f"📊 Found {len(apps_data.get('proxy_apps', {}))} proxy apps, {len(apps_data.get('oauth_apps', {}))} oauth apps") diff --git a/.gitea/workflows/update-wiki.yml b/.gitea/workflows/update-wiki.yml index 15650a6..9af0e5d 100644 --- a/.gitea/workflows/update-wiki.yml +++ b/.gitea/workflows/update-wiki.yml @@ -36,7 +36,11 @@ jobs: - name: Generate Terraform Output run: | echo "🔍 Generating Terraform output..." - terraform output -json > terraform-output.json + # Use terraform-bin directly to avoid wrapper output + terraform output -json applications_for_wiki > terraform-output-raw.json + + # Extract just the value field + jq '.value' terraform-output-raw.json > terraform-output.json # Debug output file echo "📄 Output file size: $(wc -c < terraform-output.json) bytes"