mirror of
https://github.com/tiennm99/miti99bot.git
synced 2026-04-28 00:20:38 +00:00
feat(loldle): port classic-mode game from loldle repo
Adds loldle module with classic-mode champion guessing. Ports comparison logic from tiennm99/loldle (lib/classic-mode.js) and bundles champion data from tiennm99/loldle-data. Adds GH Actions workflow that re-syncs champions.json on cross-repo dispatch from loldle-data. - Three public commands: /loldle, /loldle_giveup, /loldle_stats - Per-user daily state + streak stats in KV (3-day TTL on games) - champions-data.js wrapper sidesteps Node 24 / esbuild disagreement on JSON import attributes; generator script + npm run build:loldle-data - register script now tolerates missing .env.deploy (env-file-if-exists) so Workers Builds can inject env vars directly - fix(scripts): escape stray */ in migrate.js docstring that broke node - 16 new unit tests (compare, daily, lookup); dispatcher test updated for the new command set
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
name: Sync loldle data
|
||||
|
||||
on:
|
||||
repository_dispatch:
|
||||
types: [loldle-data-updated]
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
# Safety net: runs Friday 07:00 UTC (~25h after loldle-data's Thursday job)
|
||||
# in case the dispatch event was missed.
|
||||
- cron: "0 7 * * 5"
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
sync:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v5
|
||||
|
||||
- name: Download latest champions.json
|
||||
run: |
|
||||
curl -fsSL -o src/modules/loldle/champions.json.new \
|
||||
https://raw.githubusercontent.com/tiennm99/loldle-data/main/champions.json
|
||||
|
||||
- name: Compare and replace
|
||||
id: diff
|
||||
run: |
|
||||
if cmp -s src/modules/loldle/champions.json src/modules/loldle/champions.json.new; then
|
||||
echo "No changes."
|
||||
rm src/modules/loldle/champions.json.new
|
||||
echo "changed=false" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
mv src/modules/loldle/champions.json.new src/modules/loldle/champions.json
|
||||
echo "changed=true" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
- name: Regenerate champions-data.js
|
||||
if: steps.diff.outputs.changed == 'true'
|
||||
run: node scripts/build-loldle-data.js
|
||||
|
||||
- name: Commit and push
|
||||
if: steps.diff.outputs.changed == 'true'
|
||||
run: |
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git add src/modules/loldle/champions.json src/modules/loldle/champions-data.js
|
||||
git commit -m "chore(loldle): sync champions.json from loldle-data"
|
||||
git push
|
||||
Reference in New Issue
Block a user