Files
Fu-Jie_openwebui-extensions/.github/workflows/community-stats.yml

92 lines
2.9 KiB
YAML
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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
# - 新增插件 (total_posts)
# - 插件版本变更 (version)
# - 积分增加 (total_points)
# - 粉丝增加 (followers)
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: Capture existing stats (before update)
id: old_stats
run: |
if [ -f docs/community-stats.json ]; then
echo "total_posts=$(jq -r '.total_posts // 0' docs/community-stats.json)" >> $GITHUB_OUTPUT
else
echo "total_posts=0" >> $GITHUB_OUTPUT
fi
- name: Generate stats report
env:
OPENWEBUI_API_KEY: ${{ secrets.OPENWEBUI_API_KEY }}
OPENWEBUI_USER_ID: ${{ secrets.OPENWEBUI_USER_ID }}
GIST_TOKEN: ${{ secrets.GIST_TOKEN }}
GIST_ID: ${{ secrets.GIST_ID }}
run: |
python scripts/openwebui_stats.py
- name: Capture new stats (after update)
id: new_stats
run: |
echo "total_posts=$(jq -r '.total_posts // 0' docs/community-stats.json)" >> $GITHUB_OUTPUT
- name: Check for significant changes
id: check_changes
run: |
OLD_POSTS="${{ steps.old_stats.outputs.total_posts }}"
NEW_POSTS="${{ steps.new_stats.outputs.total_posts }}"
SHOULD_COMMIT="false"
CHANGE_REASON=""
if [ "$NEW_POSTS" -gt "$OLD_POSTS" ]; then
SHOULD_COMMIT="true"
CHANGE_REASON="new plugin added ($OLD_POSTS -> $NEW_POSTS)"
echo "📦 New plugin detected: $OLD_POSTS -> $NEW_POSTS"
fi
echo "should_commit=$SHOULD_COMMIT" >> $GITHUB_OUTPUT
echo "change_reason=$CHANGE_REASON" >> $GITHUB_OUTPUT
if [ "$SHOULD_COMMIT" = "false" ]; then
echo " No significant changes detected, skipping commit"
else
echo "✅ Significant changes detected: $CHANGE_REASON"
fi
- name: Commit and push changes
if: steps.check_changes.outputs.should_commit == '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/ README.md README_CN.md
git diff --staged --quiet || git commit -m "chore: update community stats - ${{ steps.check_changes.outputs.change_reason }}"
git push