Skip to content

Simple todo list

Simple todo list #341

Workflow file for this run

name: Update Leaderboard
on:
pull_request_target:
types: [closed]
workflow_dispatch: # Allow manual trigger for testing
permissions:
contents: write
pull-requests: read
jobs:
update:
if: github.event_name == 'workflow_dispatch' || github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: Checkout repository (base branch / safe context)
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
# If this run was triggered by a pull_request_target event, check out the base branch.
# For workflow_dispatch, fallback to the workflow ref (github.ref).
ref: ${{ github.event.pull_request && github.event.pull_request.base.ref || github.ref }}
submodules: false # Explicitly disable submodules to avoid warnings
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Run leaderboard update script
run: node scripts/updateLeaderboard.js
env:
PR_NUMBER: ${{ github.event.pull_request && github.event.pull_request.number || '' }}
PR_AUTHOR: ${{ github.event.pull_request && github.event.pull_request.user.login || '' }}
continue-on-error: false # Fail the workflow if script fails
- name: Verify leaderboard files were generated
run: |
if [ ! -f "DomainsLeaderboards/Overall.md" ]; then
echo "❌ Error: Overall.md was not generated!"
exit 1
fi
if [ ! -f "HallOfFame/README.md" ]; then
echo "❌ Error: Hall of Fame README.md was not generated!"
exit 1
fi
echo "✅ Leaderboard files generated successfully"
echo "📊 Contributors in Overall.md:"
grep -c "@" DomainsLeaderboards/Overall.md || echo "0"
- name: Check for changes
id: check_changes
run: |
git diff --quiet DomainsLeaderboards/Overall.md HallOfFame/README.md || echo "changes=true" >> $GITHUB_OUTPUT
- name: Commit and push changes
if: steps.check_changes.outputs.changes == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add DomainsLeaderboards/Overall.md
git add HallOfFame/README.md
# Show what's being committed
echo "📝 Changes to be committed:"
git diff --cached --stat
git commit -m "chore: Update leaderboard and Hall of Fame after PR #${{ github.event.pull_request.number }}" || exit 0
# Ensure the git remote uses the authenticated token
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}.git
# Push with error handling
if git push origin HEAD; then
echo "✅ Successfully pushed leaderboard updates"
else
echo "❌ Failed to push changes"
exit 1
fi
- name: Success notification
if: steps.check_changes.outputs.changes == 'true'
run: echo "✅ Leaderboard and Hall of Fame updated successfully!"
- name: No changes notification
if: steps.check_changes.outputs.changes != 'true'
run: echo "ℹ️ No changes detected in leaderboard files."