name: update invidious
on:
  workflow_dispatch:
  schedule:
    - cron: '0 0 1 * *' # check every month

jobs:
  check-list:
    runs-on: ubuntu-latest 
    steps:
      - uses: actions/checkout@v3
      - name: Download instance list
        run: |
          wget https://api.invidious.io/instances.json -O ci/data.json
      - name: Install dependencies
        run: npm ci
      - name: "Run CI"
        run: npm run ci:invidious

      - name: Create pull request to update list
        uses: peter-evans/create-pull-request@2b011faafdcbc9ceb11414d64d0573f37c774b04
        # v4.2.3
        with:
          commit-message: Update Invidious List
          author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
          branch: ci/update_invidious_list
          title: Update Invidious List
          body: Automated Invidious list update