mirror of
https://github.com/tiennm99/loldle.git
synced 2026-10-13 14:16:14 +00:00
- Single LOLDLE_PAT secret for all downstream repos (miti99bot + loldle). - sync_repo() takes (repo, dest-path, optional post-copy command); add a target by appending one line. - DRYs up duplicate clone/copy/commit/push blocks.
75 lines
2.3 KiB
YAML
75 lines
2.3 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"
|
|
|
|
# Fan out updated champions.json to downstream repos.
|
|
# Each row: <repo> <dest-path> [post-copy command].
|
|
# Add a new target by appending one line — no other edits required.
|
|
- name: Sync to downstream repos
|
|
if: steps.commit.outputs.changed == 'true'
|
|
env:
|
|
GH_PAT: ${{ secrets.LOLDLE_PAT }}
|
|
run: |
|
|
set -euo pipefail
|
|
git config --global user.name "github-actions[bot]"
|
|
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
|
|
|
sync_repo() {
|
|
local repo=$1 dest=$2 post=${3:-}
|
|
local dir=${repo##*/}
|
|
git clone --depth 1 \
|
|
"https://x-access-token:${GH_PAT}@github.com/${repo}.git" "$dir"
|
|
cp champions.json "$dir/$dest"
|
|
(
|
|
cd "$dir"
|
|
if [ -n "$post" ]; then eval "$post"; fi
|
|
git add -A
|
|
if git diff --cached --quiet; then
|
|
echo "$repo already up to date"
|
|
exit 0
|
|
fi
|
|
git commit -m "chore(data): sync champions from loldle-data@${GITHUB_SHA::7}"
|
|
git push
|
|
)
|
|
}
|
|
|
|
sync_repo tiennm99/miti99bot src/modules/loldle/champions.json "node scripts/build-loldle-data.js"
|
|
sync_repo tiennm99/loldle public/champions.json
|