Files
Fu-Jie_openwebui-extensions/.github/workflows/community-stats.yml
fujie 80cf2b5a52 feat: switch to dynamic badges - no more stats commits
- Replace README stats tables with Shields.io dynamic badges
- Badges data stored in GitHub Gist (ID: 7beb87fdc36bf10408282b1db495fe55)
- Workflow only uploads to Gist, never commits to main branch
- Stats refresh hourly via GitHub Actions
2026-01-08 22:33:46 +08:00

79 lines
2.3 KiB
YAML

# OpenWebUI 社区统计报告自动生成
# 使用 GitHub Gist 存储动态徽章数据,完全不 commit 到主仓库
name: Community Stats
on:
# 每小时整点运行
schedule:
- cron: '0 * * * *'
# 手动触发
workflow_dispatch:
jobs:
update-stats:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
run: |
pip install requests python-dotenv
- name: Generate stats report
env:
OPENWEBUI_API_KEY: ${{ secrets.OPENWEBUI_API_KEY }}
OPENWEBUI_USER_ID: ${{ secrets.OPENWEBUI_USER_ID }}
run: |
python scripts/openwebui_stats.py
- name: Upload badges to Gist
env:
GIST_TOKEN: ${{ secrets.GIST_TOKEN }}
GIST_ID: ${{ secrets.GIST_ID }}
run: |
if [ -z "$GIST_TOKEN" ] || [ -z "$GIST_ID" ]; then
echo "⚠️ GIST_TOKEN or GIST_ID not set, skipping Gist upload"
exit 0
fi
echo "📤 Uploading badges to Gist..."
# Build JSON payload with all badge files
files_json="{"
first=true
for badge in docs/badges/*.json; do
filename=$(basename "$badge")
content=$(cat "$badge" | sed 's/"/\\"/g' | tr -d '\n')
if [ "$first" = true ]; then
first=false
else
files_json+=","
fi
files_json+="\"$filename\":{\"content\":\"$content\"}"
done
files_json+="}"
# Update Gist with all files at once
response=$(curl -s -X PATCH \
-H "Authorization: token $GIST_TOKEN" \
-H "Accept: application/vnd.github+json" \
"https://api.github.com/gists/$GIST_ID" \
-d "{\"files\":$files_json}")
if echo "$response" | grep -q '"id"'; then
echo "✅ Successfully updated Gist: https://gist.github.com/$GIST_ID"
else
echo "❌ Failed to update Gist"
echo "$response"
exit 1
fi