Added wiki generator
Some checks failed
Terraform / Terraform (push) Has been cancelled
Update Authentik Applications Wiki / Generate and Update Wiki (push) Failing after 19s

This commit is contained in:
AB from home.homenet
2025-09-16 16:01:41 +03:00
parent 18c64ef812
commit 1184ff9060
2 changed files with 44 additions and 12 deletions

View File

@@ -108,20 +108,45 @@ def main():
output_file = sys.argv[1] output_file = sys.argv[1]
try: try:
with open(output_file, 'r') as f: # Check if file exists and has content
terraform_output = json.load(f) 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', {}) apps_data = terraform_output.get('applications_for_wiki', {}).get('value', {})
if not apps_data: if not apps_data:
print("ERROR: No applications_for_wiki output found in Terraform output") print("ERROR: No applications_for_wiki output found in Terraform output")
print(f"Available outputs: {list(terraform_output.keys())}")
sys.exit(1) 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) markdown_content = generate_markdown_table(apps_data)
# Записываем результат # Write result
wiki_file = "Applications.md" wiki_file = "Applications.md"
with open(wiki_file, 'w', encoding='utf-8') as f: with open(wiki_file, 'w', encoding='utf-8') as f:
f.write(markdown_content) f.write(markdown_content)
@@ -129,12 +154,6 @@ def main():
print(f"✅ Wiki page generated: {wiki_file}") print(f"✅ Wiki page generated: {wiki_file}")
print(f"📊 Total applications: {len(apps_data.get('proxy_apps', {})) + len(apps_data.get('oauth_apps', {}))}") 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: except Exception as e:
print(f"ERROR: {e}") print(f"ERROR: {e}")
sys.exit(1) sys.exit(1)

View File

@@ -35,12 +35,25 @@ jobs:
- name: Generate Terraform Output - name: Generate Terraform Output
run: | run: |
echo "🔍 Generating Terraform output..."
terraform output -json > terraform-output.json 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" echo "✅ Terraform output generated"
- name: Generate Wiki Content - name: Generate Wiki Content
run: | 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 python3 ../../.gitea/scripts/generate-apps-wiki.py terraform-output.json
echo "✅ Wiki content generated" echo "✅ Wiki content generated"