Files
Fu-Jie_openwebui-extensions/.github/workflows/community-stats.yml
2026-01-08 23:21:04 +08:00

79 lines
2.6 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# OpenWebUI 社区统计报告自动生成
# 只在统计数据变化时 commit避免频繁提交
name: Community Stats
on:
# 每小时整点运行
schedule:
- cron: '0 * * * *'
# 手动触发
workflow_dispatch:
permissions:
contents: write
jobs:
update-stats:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
run: |
pip install requests python-dotenv
- name: Get previous stats
id: prev_stats
run: |
# 获取当前的 points 用于比较
if [ -f docs/community-stats.json ]; then
OLD_POINTS=$(jq -r '.user.total_points' docs/community-stats.json 2>/dev/null || echo "0")
echo "old_points=$OLD_POINTS" >> $GITHUB_OUTPUT
else
echo "old_points=0" >> $GITHUB_OUTPUT
fi
- 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: Check for significant changes
id: check_changes
run: |
# 获取新的 points
NEW_POINTS=$(jq -r '.user.total_points' docs/community-stats.json 2>/dev/null || echo "0")
echo "📊 Previous points: ${{ steps.prev_stats.outputs.old_points }}"
echo "📊 Current points: $NEW_POINTS"
# 只在 points 变化时才 commit
if [ "$NEW_POINTS" != "${{ steps.prev_stats.outputs.old_points }}" ]; then
echo "changed=true" >> $GITHUB_OUTPUT
echo "✅ Points changed (${{ steps.prev_stats.outputs.old_points }} → $NEW_POINTS), will commit"
else
echo "changed=false" >> $GITHUB_OUTPUT
echo "⏭️ Points unchanged, skipping commit"
fi
- name: Commit and push changes
if: steps.check_changes.outputs.changed == 'true'
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add docs/community-stats.zh.md docs/community-stats.md docs/community-stats.json README.md README_CN.md
git diff --staged --quiet || git commit -m "chore: update community stats $(date +'%Y-%m-%d')"
git push