name: Update Contributors

on:
  push:
    branches:
      - master

permissions:
  contents: read

jobs:
  build:
    # Disables this workflow from running in a repository that is not part of the indicated organization/user
    if: github.repository_owner == 'cookiecutter'
    permissions:
      contents: write # for stefanzweifel/git-auto-commit-action to push code in repo

    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Install uv
        uses: astral-sh/setup-uv@v5
      - name: Update list
        run: uv run --frozen scripts/update_contributors.py
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

      - name: Commit changes
        uses: stefanzweifel/git-auto-commit-action@v5.0.1
        with:
          commit_message: Update Contributors
          file_pattern: CONTRIBUTORS.md .github/contributors.json
