name: Generate Sponsors List
on:
  workflow_dispatch:

permissions:
  contents: write
  pull-requests: write

jobs:
  generate-sponsors:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

      - name: Generate Sponsors
        uses: JamesIves/github-sponsors-readme-action@02650b8cd445fc16dfef73195f9c406dce041623 # v1.6.1
        with:
          token: ${{ secrets.SPONSORS_GENERATOR_PAT }}
          active-only: false
          file: "README.md"
          template: '<a href="https://github.com/{{{ login }}}"><img src="{{{ avatarUrl }}}" width="64px" alt="User avatar: {{{ login }}}" /></a>&nbsp;&nbsp;'

      - name: Create Pull Request
        uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          commit-message: |
            docs: regenerate readme sponsors list
          committer: GitHub <noreply@github.com>
          author: GitHub <noreply@github.com>
          branch: docs/update-readme
          title: |
            docs: regenerate readme sponsors list
          labels: bot
