Skip to content

Commit 31e6cbc

Browse files
committed
chore: 检查推送中的所有提交,这样即使自动合并、被覆盖了也能处理
1 parent 5ae7adb commit 31e6cbc

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

.github/workflows/update-readme.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ permissions:
1111

1212
jobs:
1313
update-readme:
14-
# 只有 commit message 包含 [ptr] 时才执行
15-
if: contains(github.event.head_commit.message, '[ptr]')
1614
runs-on: ubuntu-latest
1715

1816
steps:
@@ -27,14 +25,28 @@ jobs:
2725
with:
2826
node-version: '18'
2927

28+
# 检查推送中的所有提交是否包含 [ptr]
29+
- name: Check for [ptr] in commits
30+
id: check_ptr
31+
run: |
32+
# 获取所有推送的提交消息
33+
COMMITS=$(git log --format=%B ${{ github.event.before }}..${{ github.sha }})
34+
if echo "$COMMITS" | grep -q "\[ptr\]"; then
35+
echo "has_ptr=true" >> $GITHUB_OUTPUT
36+
else
37+
echo "has_ptr=false" >> $GITHUB_OUTPUT
38+
fi
39+
3040
- name: Update README
41+
if: steps.check_ptr.outputs.has_ptr == 'true'
3142
env:
3243
COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
3344
COMMIT_SHA: ${{ github.sha }}
3445
REPO_URL: ${{ github.server_url }}/${{ github.repository }}
3546
run: node scripts/update-readme.js
3647

3748
- name: Commit changes
49+
if: steps.check_ptr.outputs.has_ptr == 'true'
3850
uses: stefanzweifel/git-auto-commit-action@v4
3951
with:
4052
commit_message: "docs: auto update README [skip ci]"

0 commit comments

Comments
 (0)