name: update-pr-references
on:
  push:
    branches:
      - main

jobs:
  update_pr_numbers_in_change_fragments:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
      - uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
        with:
          python-version: '3.x'
      - name: update any PR numbers in change fragments
        run: |
          python ./changelog.d/update-pr-refs.py
          if [ "$(git status --porcelain)" = "" ]; then
            echo "no changes"
          else
            git add changelog.d/
            git \
              -c user.name="GitHub Actions" \
              -c user.email="actions@github.com" \
              commit -m '(actions) update PR references'
            git push origin
          fi
