From d2bf2a39a2b32bf1ad628550c6391a8c922b99ea Mon Sep 17 00:00:00 2001 From: tiennm99 Date: Sat, 25 Jul 2026 09:52:11 +0700 Subject: [PATCH] ci: pull champions data from loldle-data weekly Replaces the upstream push-based fan-out with a scheduled pull, so this repo owns its own data refresh. Deploy is dispatched explicitly because a GITHUB_TOKEN push does not trigger workflows. --- web/.github/workflows/sync-data.yml | 53 +++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 web/.github/workflows/sync-data.yml diff --git a/web/.github/workflows/sync-data.yml b/web/.github/workflows/sync-data.yml new file mode 100644 index 0000000..8d27517 --- /dev/null +++ b/web/.github/workflows/sync-data.yml @@ -0,0 +1,53 @@ +name: Sync champions data + +on: + schedule: + # Every Monday at 06:00 UTC + - cron: '0 6 * * 1' + workflow_dispatch: + +permissions: + contents: write + actions: write + +concurrency: + group: sync-data + cancel-in-progress: false + +jobs: + sync: + runs-on: ubuntu-latest + env: + GH_TOKEN: ${{ github.token }} + SOURCE_REPO: tiennm99/loldle-data + steps: + - uses: actions/checkout@v7 + + - name: Fetch champions.json from loldle-data + run: | + set -euo pipefail + sha=$(gh api "repos/$SOURCE_REPO/commits/main" --jq .sha) + gh api "repos/$SOURCE_REPO/contents/champions.json?ref=$sha" \ + -H "Accept: application/vnd.github.raw" > public/champions.json + echo "SOURCE_SHA=${sha:0:7}" >> "$GITHUB_ENV" + + - name: Commit if changed + id: commit + run: | + set -euo pipefail + if git diff --quiet -- public/champions.json; then + echo "public/champions.json already matches loldle-data@$SOURCE_SHA" + exit 0 + fi + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git add public/champions.json + git commit -m "chore(data): sync champions from loldle-data@$SOURCE_SHA" + git push + echo "changed=true" >> "$GITHUB_OUTPUT" + + # A push made with GITHUB_TOKEN does not trigger other workflows, + # so the Pages deploy has to be started explicitly. + - name: Trigger deploy + if: steps.commit.outputs.changed == 'true' + run: gh workflow run deploy.yml --ref main