Skip to content

Sync Rebrickable

Sync Rebrickable #28

Workflow file for this run

name: Sync Rebrickable
on:
schedule:
# Daily at 06:30 UTC (offset from warhammer-oracle at 06:00)
- cron: "30 6 * * *"
workflow_dispatch:
permissions:
contents: write
id-token: write
jobs:
sync:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: 22
registry-url: https://registry.npmjs.org
cache: npm
- run: npm ci
- name: Fetch latest Rebrickable data
run: npm run fetch-data
- name: Check for data changes
id: diff
run: |
if git diff --quiet src/data/; then
echo "changed=false" >> "$GITHUB_OUTPUT"
echo "Data is up to date"
else
echo "changed=true" >> "$GITHUB_OUTPUT"
echo "Data has changed:"
git diff --stat src/data/
fi
- name: Build
if: steps.diff.outputs.changed == 'true'
run: npm run build
- name: Test
if: steps.diff.outputs.changed == 'true'
run: npm test
- name: Commit updated data
if: steps.diff.outputs.changed == 'true'
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add src/data/
git commit -m "chore: sync Rebrickable data ($(date -u +%Y-%m-%d))"
git pull --rebase
git push
- name: Bump version and publish to npm
if: steps.diff.outputs.changed == 'true'
run: |
npm version patch --no-git-tag-version
npm run build
npm publish --access public --provenance
# Commit the version bump
git add package.json package-lock.json
git commit -m "chore: bump version for data sync publish"
git pull --rebase
git push