name: Weekly Platform Sync on: schedule: - cron: "0 6 * * 1" # Every Monday at 06:00 UTC workflow_dispatch: permissions: contents: write pull-requests: write concurrency: group: watch-updates cancel-in-progress: true jobs: scrape-and-update: runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 with: fetch-depth: 0 - uses: actions/setup-python@v6 with: python-version: "3.12" - name: Install dependencies run: pip install pyyaml - name: Regenerate platform configs from stable upstream sources run: | python3 -c " import sys, yaml sys.path.insert(0, 'scripts') def str_representer(dumper, data): if any(c in data for c in '()[]{}:#'): return dumper.represent_scalar('tag:yaml.org,2002:str', data, style='\"') return dumper.represent_scalar('tag:yaml.org,2002:str', data) yaml.add_representer(str, str_representer) targets = { 'libretro': 'retroarch', 'batocera': 'batocera', 'recalbox': 'recalbox', 'retrobat': 'retrobat', 'romm': 'romm', 'bizhawk': 'bizhawk', 'retrodeck': 'retrodeck', 'emudeck': 'emudeck', 'rocknix': 'rocknix', 'misterfpga': 'misterfpga', } for scraper_name, out in targets.items(): mod = __import__(f'scraper.{scraper_name}_scraper', fromlist=['Scraper']) config = mod.Scraper().generate_platform_yaml() with open(f'platforms/{out}.yml', 'w') as f: yaml.dump(config, f, default_flow_style=False, allow_unicode=True, sort_keys=False) print(f'{out}: {len(config[\"systems\"])} systems, version={config[\"version\"]}') " - name: Refresh hardware target configs run: | python -m scripts.scraper.targets.batocera_targets_scraper -o platforms/targets/batocera.yml python -m scripts.scraper.targets.retroarch_targets_scraper -o platforms/targets/retroarch.yml python -m scripts.scraper.targets.emudeck_targets_scraper -o platforms/targets/emudeck.yml python -m scripts.scraper.targets.retropie_targets_scraper -o platforms/targets/retropie.yml continue-on-error: true - name: Auto-fetch missing BIOS files run: | python scripts/generate_db.py --bios-dir bios --output database.json python scripts/auto_fetch.py --all 2>&1 | tee /tmp/fetch_report.txt || true - name: Refresh data directories run: python scripts/refresh_data_dirs.py --force - name: Deduplicate BIOS files run: python scripts/dedup.py - name: Regenerate database and documentation run: | python scripts/generate_db.py --force --bios-dir bios --output database.json python scripts/generate_readme.py --db database.json --platforms-dir platforms - name: Check for changes id: check run: | if git diff --quiet && [ -z "$(git ls-files --others --exclude-standard)" ]; then echo "has_changes=false" >> "$GITHUB_OUTPUT" else echo "has_changes=true" >> "$GITHUB_OUTPUT" echo "Changes detected:" git diff --stat git ls-files --others --exclude-standard | head -20 fi - name: Create or update PR if: steps.check.outputs.has_changes == 'true' run: | DATE=$(date +%Y-%m-%d) BRANCH="auto/update-platforms-${DATE}" git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" git checkout -b "$BRANCH" git add bios/ platforms/ database.json README.md CONTRIBUTING.md git commit -m "chore: auto-update platform data ($DATE)" git push origin "$BRANCH" --force-with-lease existing_pr=$(gh pr list --head "$BRANCH" --json number --jq '.[0].number' 2>/dev/null || true) if [ -n "$existing_pr" ] && [ "$existing_pr" != "null" ]; then echo "Updating existing PR #${existing_pr}" else gh pr create \ --title "Auto-update: Platform data ($DATE)" \ --body "$(cat <<'EOF' ## Automated Platform Update This PR was automatically generated by the weekly platform watch. ### What changed - Scraped latest BIOS requirements from libretro System.dat and batocera-systems - Auto-fetched new BIOS files from public sources - Deduplicated and regenerated database + documentation ### Review Checklist - [ ] New BIOS files are valid - [ ] Platform configs are correct - [ ] database.json and README look good --- *Auto-generated by [watch-updates](../../actions/workflows/watch-updates.yml)* EOF )" \ --label "automated,platform-update" fi env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}