name: 'Update static data'
on:
  schedule:
    - cron: '0 0 * * 0' # Every Sunday at midnight
  workflow_dispatch:

env:
  NODE_VERSION: 22

permissions: {}

jobs:
  update-data:
    runs-on: ubuntu-latest
    permissions:
      contents: write
      pull-requests: write
    steps:
      - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
        with:
          show-progress: false

      - name: Setup pnpm
        uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0
        with:
          standalone: true

      - name: Set up Node.js ${{ env.NODE_VERSION }}
        uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
        with:
          node-version: ${{ env.NODE_VERSION }}
          cache: pnpm

      - name: Install dependencies
        run: pnpm install --frozen-lockfile

      - name: Update static data
        run: pnpm run update-static-data

      - name: Run Prettier
        run: pnpm prettier-fix

      - name: Create pull request
        uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
        with:
          author: 'Renovate Bot <renovate@whitesourcesoftware.com>'
          branch: 'chore/update-static-data'
          commit-message: 'fix(data): automatic update of static data'
          committer: 'Renovate Bot <renovate@whitesourcesoftware.com>'
          title: 'fix(data): automatic update of static data'
          assignees: rarkins,viceice
