Files
homelab/.gitea/workflows/update-wiki.yml
AB from home.homenet 3daf7cf79a
Some checks failed
Terraform / Terraform (push) Successful in 29s
Check with kubeconform / lint (push) Successful in 8s
Update Authentik Applications Wiki / Generate and Update Wiki (push) Failing after 20s
Added wiki generator
2025-09-16 15:56:17 +03:00

108 lines
3.5 KiB
YAML

name: 'Update Authentik Applications Wiki'
on:
push:
branches: [ "main" ]
# paths:
# - 'terraform/authentik/**'
workflow_dispatch:
permissions:
contents: read
jobs:
update-wiki:
name: 'Generate and Update Wiki'
runs-on: ubuntu-latest
environment: production
defaults:
run:
shell: bash
working-directory: ./terraform/authentik
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
with:
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}
- name: Terraform Init
run: terraform init
- name: Generate Terraform Output
run: |
terraform output -json > terraform-output.json
echo "✅ Terraform output generated"
- name: Generate Wiki Content
run: |
python3 ../../.gitea/scripts/generate-apps-wiki.py terraform-output.json
echo "✅ Wiki content generated"
- name: Upload Wiki to Gitea
run: |
# Set variables
GITEA_URL="${{ secrets.GT_WIKI_URL }}"
GITEA_TOKEN="${{ secrets.GT_WIKI_TOKEN }}"
GITEA_OWNER="${{ secrets.GT_WIKI_OWNER }}"
GITEA_REPO="${{ secrets.GT_WIKI_REPO }}"
# Check if file was created
if [ ! -f "Applications.md" ]; then
echo "❌ Applications.md not found"
exit 1
fi
echo "📤 Uploading to Gitea Wiki..."
# Encode content to base64
CONTENT=$(base64 -w 0 Applications.md)
# Check if wiki page exists
WIKI_PAGE_EXISTS=$(curl -s -o /dev/null -w "%{http_code}" \
-H "Authorization: token $GITEA_TOKEN" \
"$GITEA_URL/api/v1/repos/$GITEA_OWNER/$GITEA_REPO/wiki/page/Applications")
if [ "$WIKI_PAGE_EXISTS" = "200" ]; then
echo "📝 Updating existing wiki page..."
# Update existing page
curl -X PATCH \
-H "Authorization: token $GITEA_TOKEN" \
-H "Content-Type: application/json" \
-d "{
\"title\": \"Applications\",
\"content_base64\": \"$CONTENT\",
\"message\": \"Update applications list from CI/CD [$(date)]\"
}" \
"$GITEA_URL/api/v1/repos/$GITEA_OWNER/$GITEA_REPO/wiki/page/Applications"
else
echo "📄 Creating new wiki page..."
# Create new page
curl -X POST \
-H "Authorization: token $GITEA_TOKEN" \
-H "Content-Type: application/json" \
-d "{
\"title\": \"Applications\",
\"content_base64\": \"$CONTENT\",
\"message\": \"Create applications list from CI/CD [$(date)]\"
}" \
"$GITEA_URL/api/v1/repos/$GITEA_OWNER/$GITEA_REPO/wiki/new"
fi
echo "✅ Wiki updated successfully!"
echo "🔗 Wiki URL: $GITEA_URL/$GITEA_OWNER/$GITEA_REPO/wiki/Applications"
- name: Summary
run: |
echo "## 📊 Wiki Update Summary" >> $GITHUB_STEP_SUMMARY
echo "- ✅ Terraform output extracted" >> $GITHUB_STEP_SUMMARY
echo "- ✅ Applications table generated" >> $GITHUB_STEP_SUMMARY
echo "- ✅ Wiki page updated in Gitea" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Applications count:** $(grep -c '|.*|.*|.*|.*|.*|' Applications.md || echo 0)" >> $GITHUB_STEP_SUMMARY
echo "**Generated at:** $(date)" >> $GITHUB_STEP_SUMMARY