Skip to content

meta-db-updated

meta-db-updated #31

Workflow file for this run

name: Update Meta DB
on:
# Pushed by LeagueToolkit/lol-meta-classes as soon as db/meta.db.json moves,
# so a new patch reaches the site in minutes rather than waiting for the cron.
repository_dispatch:
types: [meta-db-updated]
# Fallback for a missed or unauthenticated dispatch (expired token, failed
# upstream run). Weekly, shortly after lol-meta-classes' Sunday sync.
schedule:
- cron: '0 6 * * 0'
workflow_dispatch:
jobs:
update:
runs-on: ubuntu-latest
permissions:
contents: write
# For the explicit deploy trigger below.
actions: write
steps:
- uses: actions/checkout@v4
with:
persist-credentials: true
- uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- name: Fetch latest meta.db.json
run: bun scripts/update-db.ts
- name: Commit and push if changed
id: commit
run: |
set -e
if git diff --quiet -- db/meta.db.json; then
echo "Database is already up to date."
echo "pushed=false" >> $GITHUB_OUTPUT
exit 0
fi
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
PATCH=$(python3 -c "import json; db = json.load(open('db/meta.db.json')); print(db['versions'][-1]['patch'])")
git add db/meta.db.json
git commit -m "chore: update meta db to patch ${PATCH}"
git push
echo "pushed=true" >> $GITHUB_OUTPUT
# The push above is made with GITHUB_TOKEN, and GitHub does not raise
# `push` events for those - so deploy.yml would never see this commit and
# the new patch would sit in the repo, unpublished, until an unrelated
# human push happened to carry it out. Trigger it by hand.
- name: Trigger deploy
if: steps.commit.outputs.pushed == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh workflow run deploy.yml --ref main