mirror of
https://github.com/tiennm99/loldle.git
synced 2026-10-11 03:13:42 +00:00
Replaces the repository_dispatch notification flow. After a successful champions.json commit in loldle-data, this workflow now clones miti99bot, copies the file, regenerates champions-data.js via the project's build script, and commits+pushes to miti99bot main. Token secret renamed MITI99BOT_DISPATCH_TOKEN -> MITI99BOT_PUSH_TOKEN to reflect the new scope (contents:write on tiennm99/miti99bot).
62 lines
1.9 KiB
YAML
62 lines
1.9 KiB
YAML
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
|
|
id: commit
|
|
run: |
|
|
git config user.name "github-actions[bot]"
|
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
|
git add champions.json
|
|
if git diff --cached --quiet; then
|
|
echo "No changes to commit"
|
|
echo "changed=false" >> "$GITHUB_OUTPUT"
|
|
exit 0
|
|
fi
|
|
git commit -m "chore: update champions data to latest patch"
|
|
git push
|
|
echo "changed=true" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Push to miti99bot
|
|
if: steps.commit.outputs.changed == 'true' && env.MITI99BOT_PUSH_TOKEN != ''
|
|
env:
|
|
MITI99BOT_PUSH_TOKEN: ${{ secrets.MITI99BOT_PUSH_TOKEN }}
|
|
run: |
|
|
set -euo pipefail
|
|
git clone --depth 1 \
|
|
"https://x-access-token:${MITI99BOT_PUSH_TOKEN}@github.com/tiennm99/miti99bot.git" miti99bot
|
|
cp champions.json miti99bot/src/modules/loldle/champions.json
|
|
cd miti99bot
|
|
node scripts/build-loldle-data.js
|
|
git add src/modules/loldle/champions.json src/modules/loldle/champions-data.js
|
|
if git diff --cached --quiet; then
|
|
echo "miti99bot already up to date"
|
|
exit 0
|
|
fi
|
|
git config user.name "github-actions[bot]"
|
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
|
git commit -m "chore(loldle): sync champions data from loldle-data@${GITHUB_SHA::7}"
|
|
git push
|