name: Update query hashes

on:
  schedule:
    - cron: '30 * * * *'
  workflow_dispatch:

jobs:
  check-and-create-pr:
    runs-on: ubuntu-latest

    steps:
    - name: Checkout code
      uses: actions/checkout@v4

    - name: Setup Node.js
      uses: actions/setup-node@v4
      with:
        node-version: '22'

    - name: Install dependencies
      run: npm ci

    - name: Fetch query hashes
      run: node utility/getQueryHashes.mjs > app/splatnet/queryHashes.json

    - name: Create PR
      uses: peter-evans/create-pull-request@v6
      with:
        title: Update query hashes
        commit-message: Update query hashes
        branch: update-query-hashes
        body: Update query hashes
        delete-branch: true
        reviewers: misenhower
