Files

71 lines
2.6 KiB
YAML

name: Refresh games database
# Refresh the PS5 title list from the PlayStation-Titles dataset weekly and
# enrich a batch of concepts with PlayStation Store metadata. Manual runs can
# tune the enrich count.
#
# Changes open a PR (data/games-refresh) instead of pushing to main directly:
# CI gates the diff and a bad import can't break main — the PR is merged
# manually once it looks good. Re-runs update the standing PR in place, so
# there is at most one open refresh PR at any time.
on:
schedule:
- cron: "0 4 * * 1" # Mondays 04:00 UTC
workflow_dispatch:
inputs:
enrich:
description: "Number of concepts to enrich"
default: "300"
permissions:
contents: write # push the PR branch
pull-requests: write # open the PR
jobs:
import:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- run: npm ci
- name: Import games
env:
ENRICH: ${{ github.event.inputs.enrich || '300' }}
run: |
[[ "$ENRICH" =~ ^[0-9]+$ ]] || { echo "enrich must be a number"; exit 1; }
node scripts/import-games.mjs --enrich "$ENRICH"
node scripts/export-site-compat-json.mjs --seed
CHECK_SEED_SYNC=true npm test
- name: Open refresh PR
id: cpr
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.ACTIONS_BOT_TOKEN || secrets.GITHUB_TOKEN }}
add-paths: |
src/data/games.json
src/data/compat-index.json
commit-message: "data: refresh games database"
branch: data/games-refresh
title: "data: refresh games database"
delete-branch: true
- name: Enable auto-merge for data refresh PR
if: steps.cpr.outcome == 'success' && steps.cpr.outputs.pull-request-number != ''
env:
GH_TOKEN: ${{ secrets.ACTIONS_BOT_TOKEN || secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ steps.cpr.outputs.pull-request-number }}
run: |
if gh pr merge "$PR_NUMBER" --auto --squash; then
echo "Auto-merge enabled for PR #$PR_NUMBER"
else
PR_STATUS="$(gh pr view "$PR_NUMBER" --json autoMergeRequest,state --jq '.autoMergeRequest != null or .state == "MERGED"' 2>/dev/null || true)"
if [ "$PR_STATUS" = "true" ]; then
echo "Auto-merge already enabled or merged for PR #$PR_NUMBER"
else
echo "::warning::Failed to enable auto-merge on PR #$PR_NUMBER"
fi
fi