name: Sync Fork

on:
  push:
    branches:
      - master
  pull_request:
    branches:
      - master

jobs:
  auto_index:
    runs-on: ubuntu-latest
    name: Sync latest commits from upstream repo

    steps:
      - name: Checkout target repo
        uses: actions/checkout@v3

      - uses: actions/setup-python@v4
        with:
          python-version: "3.11"
          cache: "pip"
      - run: pip install -r index/requirements.txt --upgrade
      - run: python index/generate_index.py

      - uses: stefanzweifel/git-auto-commit-action@v4
        with:
          commit_message: Auto-Update index.csv
          file_pattern: index.csv
