ci: clean up unused variables in stats workflow
This commit is contained in:
23
.github/workflows/community-stats.yml
vendored
23
.github/workflows/community-stats.yml
vendored
@@ -39,15 +39,8 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
if [ -f docs/community-stats.json ]; then
|
if [ -f docs/community-stats.json ]; then
|
||||||
echo "total_posts=$(jq -r '.total_posts // 0' docs/community-stats.json)" >> $GITHUB_OUTPUT
|
echo "total_posts=$(jq -r '.total_posts // 0' docs/community-stats.json)" >> $GITHUB_OUTPUT
|
||||||
echo "total_points=$(jq -r '.user.total_points // 0' docs/community-stats.json)" >> $GITHUB_OUTPUT
|
|
||||||
echo "followers=$(jq -r '.user.followers // 0' docs/community-stats.json)" >> $GITHUB_OUTPUT
|
|
||||||
# 提取所有插件的版本号,生成一个排序后的字符串用于比较
|
|
||||||
echo "versions=$(jq -r '[.posts[].version] | sort | join(",")' docs/community-stats.json)" >> $GITHUB_OUTPUT
|
|
||||||
else
|
else
|
||||||
echo "total_posts=0" >> $GITHUB_OUTPUT
|
echo "total_posts=0" >> $GITHUB_OUTPUT
|
||||||
echo "total_points=0" >> $GITHUB_OUTPUT
|
|
||||||
echo "followers=0" >> $GITHUB_OUTPUT
|
|
||||||
echo "versions=" >> $GITHUB_OUTPUT
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Generate stats report
|
- name: Generate stats report
|
||||||
@@ -63,36 +56,22 @@ jobs:
|
|||||||
id: new_stats
|
id: new_stats
|
||||||
run: |
|
run: |
|
||||||
echo "total_posts=$(jq -r '.total_posts // 0' docs/community-stats.json)" >> $GITHUB_OUTPUT
|
echo "total_posts=$(jq -r '.total_posts // 0' docs/community-stats.json)" >> $GITHUB_OUTPUT
|
||||||
echo "total_points=$(jq -r '.user.total_points // 0' docs/community-stats.json)" >> $GITHUB_OUTPUT
|
|
||||||
echo "followers=$(jq -r '.user.followers // 0' docs/community-stats.json)" >> $GITHUB_OUTPUT
|
|
||||||
echo "versions=$(jq -r '[.posts[].version] | sort | join(",")' docs/community-stats.json)" >> $GITHUB_OUTPUT
|
|
||||||
|
|
||||||
- name: Check for significant changes
|
- name: Check for significant changes
|
||||||
id: check_changes
|
id: check_changes
|
||||||
run: |
|
run: |
|
||||||
OLD_POSTS="${{ steps.old_stats.outputs.total_posts }}"
|
OLD_POSTS="${{ steps.old_stats.outputs.total_posts }}"
|
||||||
NEW_POSTS="${{ steps.new_stats.outputs.total_posts }}"
|
NEW_POSTS="${{ steps.new_stats.outputs.total_posts }}"
|
||||||
OLD_POINTS="${{ steps.old_stats.outputs.total_points }}"
|
|
||||||
NEW_POINTS="${{ steps.new_stats.outputs.total_points }}"
|
|
||||||
OLD_FOLLOWERS="${{ steps.old_stats.outputs.followers }}"
|
|
||||||
NEW_FOLLOWERS="${{ steps.new_stats.outputs.followers }}"
|
|
||||||
OLD_VERSIONS="${{ steps.old_stats.outputs.versions }}"
|
|
||||||
NEW_VERSIONS="${{ steps.new_stats.outputs.versions }}"
|
|
||||||
|
|
||||||
SHOULD_COMMIT="false"
|
SHOULD_COMMIT="false"
|
||||||
CHANGE_REASON=""
|
CHANGE_REASON=""
|
||||||
|
|
||||||
# 检查新增插件
|
|
||||||
if [ "$NEW_POSTS" -gt "$OLD_POSTS" ]; then
|
if [ "$NEW_POSTS" -gt "$OLD_POSTS" ]; then
|
||||||
SHOULD_COMMIT="true"
|
SHOULD_COMMIT="true"
|
||||||
CHANGE_REASON="new plugin added ($OLD_POSTS -> $NEW_POSTS)"
|
CHANGE_REASON="new plugin added ($OLD_POSTS -> $NEW_POSTS)"
|
||||||
echo "📦 New plugin detected: $OLD_POSTS -> $NEW_POSTS"
|
echo "📦 New plugin detected: $OLD_POSTS -> $NEW_POSTS"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
echo "should_commit=$SHOULD_COMMIT" >> $GITHUB_OUTPUT
|
echo "should_commit=$SHOULD_COMMIT" >> $GITHUB_OUTPUT
|
||||||
echo "change_reason=$CHANGE_REASON" >> $GITHUB_OUTPUT
|
echo "change_reason=$CHANGE_REASON" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
@@ -107,6 +86,6 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
git config --local user.email "github-actions[bot]@users.noreply.github.com"
|
git config --local user.email "github-actions[bot]@users.noreply.github.com"
|
||||||
git config --local user.name "github-actions[bot]"
|
git config --local user.name "github-actions[bot]"
|
||||||
git add docs/community-stats.zh.md docs/community-stats.md docs/community-stats.json docs/badges README.md README_CN.md
|
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 diff --staged --quiet || git commit -m "chore: update community stats - ${{ steps.check_changes.outputs.change_reason }}"
|
||||||
git push
|
git push
|
||||||
|
|||||||
Reference in New Issue
Block a user