Added wiki generator
All checks were successful
Update Kubernetes Services Wiki / Generate and Update K8s Wiki (push) Successful in 9s
All checks were successful
Update Kubernetes Services Wiki / Generate and Update K8s Wiki (push) Successful in 9s
This commit is contained in:
111
.gitea/workflows/k8s-wiki.yaml
Normal file
111
.gitea/workflows/k8s-wiki.yaml
Normal file
@@ -0,0 +1,111 @@
|
||||
name: 'Update Kubernetes Services Wiki'
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "main" ]
|
||||
# paths:
|
||||
# - 'k8s/**'
|
||||
# - '.gitea/scripts/generate-k8s-wiki.py'
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
update-k8s-wiki:
|
||||
name: 'Generate and Update K8s Wiki'
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Install Python dependencies
|
||||
run: |
|
||||
pip install pyyaml
|
||||
|
||||
- name: Generate K8s Services Wiki
|
||||
run: |
|
||||
echo "📋 Starting K8s wiki generation..."
|
||||
python3 .gitea/scripts/generate-k8s-wiki.py k8s/ Kubernetes-Services.md
|
||||
|
||||
if [ -f "Kubernetes-Services.md" ]; then
|
||||
echo "✅ Wiki content generated successfully"
|
||||
echo "📄 File size: $(wc -c < Kubernetes-Services.md) bytes"
|
||||
echo "📄 Lines: $(wc -l < Kubernetes-Services.md)"
|
||||
else
|
||||
echo "❌ Wiki content not generated"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Upload Wiki to Gitea
|
||||
continue-on-error: true
|
||||
run: |
|
||||
# Set variables
|
||||
GITEA_URL="${{ secrets.GT_URL }}"
|
||||
GITEA_TOKEN="${{ secrets.GT_WIKI_TOKEN }}"
|
||||
GITEA_OWNER="${{ secrets.GT_OWNER }}"
|
||||
GITEA_REPO="${{ secrets.GT_REPO }}"
|
||||
|
||||
# Debug variables (without exposing token)
|
||||
echo "🔍 Checking variables..."
|
||||
echo "GITEA_URL: ${GITEA_URL:-NOT SET}"
|
||||
echo "GITEA_OWNER: ${GITEA_OWNER:-NOT SET}"
|
||||
echo "GITEA_REPO: ${GITEA_REPO:-NOT SET}"
|
||||
echo "GITEA_TOKEN: $(if [ -n "$GITEA_TOKEN" ]; then echo "SET"; else echo "NOT SET"; fi)"
|
||||
|
||||
if [ ! -f "Kubernetes-Services.md" ]; then
|
||||
echo "❌ Kubernetes-Services.md not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "📤 Uploading to Gitea Wiki..."
|
||||
|
||||
# Encode content to base64
|
||||
CONTENT=$(base64 -w 0 Kubernetes-Services.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/Kubernetes-Services" || echo "000")
|
||||
|
||||
if [ "$WIKI_PAGE_EXISTS" = "200" ]; then
|
||||
echo "📝 Updating existing wiki page..."
|
||||
curl -X PATCH \
|
||||
-H "Authorization: token $GITEA_TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{
|
||||
\"title\": \"Kubernetes-Services\",
|
||||
\"content_base64\": \"$CONTENT\",
|
||||
\"message\": \"Update K8s services list from CI/CD [$(date)]\"
|
||||
}" \
|
||||
"$GITEA_URL/api/v1/repos/$GITEA_OWNER/$GITEA_REPO/wiki/page/Kubernetes-Services" || echo "⚠️ Wiki update failed"
|
||||
else
|
||||
echo "📄 Creating new wiki page..."
|
||||
curl -X POST \
|
||||
-H "Authorization: token $GITEA_TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{
|
||||
\"title\": \"Kubernetes-Services\",
|
||||
\"content_base64\": \"$CONTENT\",
|
||||
\"message\": \"Create K8s services list from CI/CD [$(date)]\"
|
||||
}" \
|
||||
"$GITEA_URL/api/v1/repos/$GITEA_OWNER/$GITEA_REPO/wiki/new" || echo "⚠️ Wiki creation failed"
|
||||
fi
|
||||
|
||||
echo "✅ Wiki update process completed"
|
||||
echo "🔗 Wiki URL: $GITEA_URL/$GITEA_OWNER/$GITEA_REPO/wiki/Kubernetes-Services"
|
||||
|
||||
- name: Summary
|
||||
if: always()
|
||||
run: |
|
||||
echo "## 📊 K8s Wiki Update Summary" >> $GITHUB_STEP_SUMMARY
|
||||
if [ -f "Kubernetes-Services.md" ]; then
|
||||
echo "- ✅ K8s services analyzed" >> $GITHUB_STEP_SUMMARY
|
||||
echo "- ✅ Wiki page generated" >> $GITHUB_STEP_SUMMARY
|
||||
echo "" >> $GITHUB_STEP_SUMMARY
|
||||
echo "**Services found:** $(grep -c '^|' Kubernetes-Services.md || echo 0)" >> $GITHUB_STEP_SUMMARY
|
||||
else
|
||||
echo "- ❌ Wiki generation failed" >> $GITHUB_STEP_SUMMARY
|
||||
fi
|
||||
echo "**Generated at:** $(date)" >> $GITHUB_STEP_SUMMARY
|
Reference in New Issue
Block a user