From c1a209806c5979e5c0021edbc50be4d98d07cc11 Mon Sep 17 00:00:00 2001 From: tiennm99 Date: Mon, 10 Aug 2026 16:29:55 +0700 Subject: [PATCH] chore: wire up monorepo layout after absorbing loldle-data and loldle-android Workflows move to the repo root: deploy and CI build from web/, and a single update-champions workflow replaces the old two-repo pipeline (scrape in data/, copy into web/static/, redeploy). Go module becomes github.com/tiennm99/loldle/data. Root README maps the three parts. --- {web/.github => .github}/workflows/ci.yml | 18 ++++++ {web/.github => .github}/workflows/deploy.yml | 8 ++- .github/workflows/update-champions.yml | 57 +++++++++++++++++++ README.md | 17 ++++++ data/.github/workflows/update-champions.yml | 37 ------------ data/README.md | 4 +- data/go.mod | 2 +- data/main.go | 2 +- data/markdown.go | 2 +- web/.github/workflows/sync-data.yml | 54 ------------------ web/README.md | 2 +- 11 files changed, 105 insertions(+), 98 deletions(-) rename {web/.github => .github}/workflows/ci.yml (61%) rename {web/.github => .github}/workflows/deploy.yml (81%) create mode 100644 .github/workflows/update-champions.yml create mode 100644 README.md delete mode 100644 data/.github/workflows/update-champions.yml delete mode 100644 web/.github/workflows/sync-data.yml diff --git a/web/.github/workflows/ci.yml b/.github/workflows/ci.yml similarity index 61% rename from web/.github/workflows/ci.yml rename to .github/workflows/ci.yml index b78b2ca..3cf5e8f 100644 --- a/web/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,15 +15,21 @@ concurrency: jobs: check: runs-on: ubuntu-latest + defaults: + run: + working-directory: web steps: - uses: actions/checkout@v7 - uses: pnpm/action-setup@v6 + with: + package_json_file: web/package.json - uses: actions/setup-node@v7 with: node-version: '24' cache: 'pnpm' + cache-dependency-path: web/pnpm-lock.yaml - run: pnpm install --frozen-lockfile --ignore-scripts @@ -34,3 +40,15 @@ jobs: # No BASE_PATH here: this checks that the app compiles. The base-path # behaviour is verified against a real preview before release. - run: pnpm build + + scraper: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v7 + + - uses: actions/setup-go@v6 + with: + go-version-file: data/go.mod + + - run: go build ./... && go test ./... + working-directory: data diff --git a/web/.github/workflows/deploy.yml b/.github/workflows/deploy.yml similarity index 81% rename from web/.github/workflows/deploy.yml rename to .github/workflows/deploy.yml index 2929e5c..8e0ac4a 100644 --- a/web/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -17,15 +17,21 @@ concurrency: jobs: build: runs-on: ubuntu-latest + defaults: + run: + working-directory: web steps: - uses: actions/checkout@v7 - uses: pnpm/action-setup@v6 + with: + package_json_file: web/package.json - uses: actions/setup-node@v7 with: node-version: '24' cache: 'pnpm' + cache-dependency-path: web/pnpm-lock.yaml - run: pnpm install --frozen-lockfile --ignore-scripts @@ -35,7 +41,7 @@ jobs: - uses: actions/upload-pages-artifact@v5 with: - path: build + path: web/build deploy: needs: build diff --git a/.github/workflows/update-champions.yml b/.github/workflows/update-champions.yml new file mode 100644 index 0000000..a3044a0 --- /dev/null +++ b/.github/workflows/update-champions.yml @@ -0,0 +1,57 @@ +name: Update champions data + +on: + schedule: + # Every Thursday at 06:00 UTC (day after Riot's Wednesday patch) + - cron: "0 6 * * 4" + workflow_dispatch: + +permissions: + contents: write + actions: write + +concurrency: + group: update-champions + cancel-in-progress: false + +jobs: + update: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v7 + + - name: Set up Go + uses: actions/setup-go@v6 + with: + go-version-file: data/go.mod + + - name: Run scraper + run: go run . + working-directory: data + + - name: Copy data into the web app + run: cp data/champions.json web/static/champions.json + + - name: Commit and push if changed + id: commit + run: | + set -euo pipefail + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git add data/champions.json data/CHAMPIONS.md web/static/champions.json + if git diff --cached --quiet; then + echo "No changes to commit" + exit 0 + fi + git commit -m "chore(data): update champions data to latest patch" + 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 + env: + GH_TOKEN: ${{ github.token }} diff --git a/README.md b/README.md new file mode 100644 index 0000000..f1302bb --- /dev/null +++ b/README.md @@ -0,0 +1,17 @@ +# loldle + +LoLdle-style League of Legends daily champion guessing game — one repository, three parts: + +| Directory | What it is | +| --- | --- | +| [`web/`](./web/) | The SvelteKit web app, deployed to [tiennm99.github.io/loldle](https://tiennm99.github.io/loldle/) | +| [`data/`](./data/) | Go scraper that refreshes `champions.json` weekly from Riot's Data Dragon API | +| [`android/`](./android/) | Android client (stub) | + +The `Update champions data` workflow runs the scraper every Thursday, copies the +result into `web/static/champions.json`, and redeploys the site when the data +changed. + +## License + +Apache-2.0 — see [LICENSE](./web/LICENSE). diff --git a/data/.github/workflows/update-champions.yml b/data/.github/workflows/update-champions.yml deleted file mode 100644 index 50d1ed2..0000000 --- a/data/.github/workflows/update-champions.yml +++ /dev/null @@ -1,37 +0,0 @@ -name: Update champions data - -on: - schedule: - # Every Thursday at 06:00 UTC (day after Riot's Wednesday patch) - - cron: "0 6 * * 4" - workflow_dispatch: - -permissions: - contents: write - -jobs: - update: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v5 - - - name: Set up Go - uses: actions/setup-go@v6 - with: - go-version-file: go.mod - - - name: Run scraper - run: go run . - - - name: Commit and push if changed - run: | - git config user.name "github-actions[bot]" - git config user.email "github-actions[bot]@users.noreply.github.com" - git add champions.json CHAMPIONS.md - if git diff --cached --quiet; then - echo "No changes to commit" - exit 0 - fi - git commit -m "chore: update champions data to latest patch" - git push diff --git a/data/README.md b/data/README.md index 7b394d0..e43cfdb 100644 --- a/data/README.md +++ b/data/README.md @@ -1,6 +1,6 @@ # loldle-data -[LoLdleData](https://github.com/Kerrders/LoLdleData) rewritten in Go — fetches League of Legends champion data from Riot's Data Dragon API and outputs a structured JSON file for use in [loldle](https://github.com/tiennm99/loldle). +[LoLdleData](https://github.com/Kerrders/LoLdleData) rewritten in Go — fetches League of Legends champion data from Riot's Data Dragon API and outputs a structured JSON file for use in the web app in [`web/`](../web/). ## What it extracts @@ -44,7 +44,7 @@ A human-readable `CHAMPIONS.md` table is also generated alongside the JSON. ## Used by -- [loldle](https://github.com/tiennm99/loldle) — the Wordle-style LoL guessing game that consumes this data. +- [`web/`](../web/) — the Wordle-style LoL guessing game that consumes this data. ## License diff --git a/data/go.mod b/data/go.mod index 04fb8e3..a0b0ba7 100644 --- a/data/go.mod +++ b/data/go.mod @@ -1,4 +1,4 @@ -module github.com/tiennm99/loldle-data +module github.com/tiennm99/loldle/data go 1.25.5 diff --git a/data/main.go b/data/main.go index abb4988..3ae967f 100644 --- a/data/main.go +++ b/data/main.go @@ -7,7 +7,7 @@ import ( "os" "sort" - "github.com/tiennm99/loldle-data/parser" + "github.com/tiennm99/loldle/data/parser" ) func main() { diff --git a/data/markdown.go b/data/markdown.go index f7cf8ee..2b6311e 100644 --- a/data/markdown.go +++ b/data/markdown.go @@ -5,7 +5,7 @@ import ( "os" "strings" - "github.com/tiennm99/loldle-data/parser" + "github.com/tiennm99/loldle/data/parser" ) // saveMarkdown renders champions as a human-readable table matching the diff --git a/web/.github/workflows/sync-data.yml b/web/.github/workflows/sync-data.yml deleted file mode 100644 index 18341ce..0000000 --- a/web/.github/workflows/sync-data.yml +++ /dev/null @@ -1,54 +0,0 @@ -name: Sync champions data - -on: - schedule: - # Thursdays 12:00 UTC, after loldle-data's own 06:00 UTC scrape - # (GitHub queues scheduled runs 2-4h late, so leave a wide margin) - - cron: '0 12 * * 4' - 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" > static/champions.json - echo "SOURCE_SHA=${sha:0:7}" >> "$GITHUB_ENV" - - - name: Commit if changed - id: commit - run: | - set -euo pipefail - if git diff --quiet -- static/champions.json; then - echo "static/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 static/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 diff --git a/web/README.md b/web/README.md index f78f3e4..35951e7 100644 --- a/web/README.md +++ b/web/README.md @@ -1,6 +1,6 @@ # loldle -LoLdle-style League of Legends daily champion guessing game — data auto-updated from [loldle-data](https://github.com/tiennm99/loldle-data). +LoLdle-style League of Legends daily champion guessing game — data auto-updated by the scraper in [`data/`](../data/). Live: https://tiennm99.github.io/loldle/