leaderboard.yml: add git diff check, add permissions #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Leaderboard | |
on: | |
push: | |
branches: [ "main" ] | |
workflow_dispatch: {} | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Update Leaderboard in README.md | |
run: ./leaderboard-replace.sh | |
- name: Output README.md changes for debugging | |
run: git diff README.md | |
- name: Commit and Push changes | |
run: | | |
set -e | |
if git diff --no-patch --exit-code README.md; then | |
git config --global user.name "${GITHUB_ACTOR}" | |
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com" | |
git commit -am "README.md: update leaderboard" \ | |
git push | |
else | |
echo "README.md unchanged, not committing" | |
fi | |