Skip to content

Update and Deploy Leaderboard #205

Update and Deploy Leaderboard

Update and Deploy Leaderboard #205

name: Update and Deploy Leaderboard
on:
schedule:
- cron: '0 */6 * * *' # Run every 6 hours
workflow_dispatch: # Allow manual trigger
permissions:
contents: write
concurrency:
group: "leaderboard-update"
cancel-in-progress: false
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install dependencies
run: npm ci
- name: Fetch Data
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npm run update-data
- name: Commit Data (Git-Scraping)
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add public/data.json
# Only commit if there are changes
if git diff --staged --quiet; then
echo "No changes to commit"
else
git commit -m "Update leaderboard data [skip ci]"
git push
fi
- name: Build Static Site
run: npm run build
- name: Archive Static Site
uses: actions/upload-artifact@v4
with:
name: static-site
path: dist/
- name: Archive Data Backup
uses: actions/upload-artifact@v4
with:
name: data-backup-${{ github.run_id }}
path: public/data.json