Skip to content

Commit 958e530

Browse files
committed
leaderboard.yml: add git diff check, add permissions
1 parent 81a09ae commit 958e530

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

.github/workflows/leaderboard.yml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,26 @@ jobs:
99

1010
build:
1111
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write
1214
steps:
1315
- uses: actions/checkout@v4
1416

1517
- name: Update Leaderboard in README.md
1618
run: ./leaderboard-replace.sh
1719

20+
- name: Output README.md changes for debugging
21+
run: git diff README.md
22+
1823
- name: Commit and Push changes
1924
run: |
20-
git config --global user.name "${GITHUB_ACTOR}"
21-
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
22-
git commit -am "README.md: update leaderboard" \
23-
&& git push \
24-
|| true
25+
set -e
26+
if git diff --no-patch --exit-code README.md; then
27+
git config --global user.name "${GITHUB_ACTOR}"
28+
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
29+
git commit -am "README.md: update leaderboard" \
30+
git push
31+
else
32+
echo "README.md unchanged, not committing"
33+
fi
2534

0 commit comments

Comments
 (0)