name: Collect plugin by PyPI listing

on:
  workflow_dispatch:
    inputs:
      project:
        description: The name of the project on PyPi
        required: true
      author:
        description: Enter the name of the author if you know it

jobs:
  build:

    runs-on: ubuntu-latest
    permissions:
      contents: write
      pull-requests: write
    steps:
      - uses: actions/checkout@v2
      - name: Get Plugin file
        run: python .github/collect_plugin.py
        env:
          PROJECT: ${{ github.event.inputs.project }}
          AUTHOR: ${{ github.event.inputs.author }}
      - name: Create Pull Request
        uses: peter-evans/create-pull-request@v4
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          commit-message: "[REPO] Add plugin ${{ github.event.inputs.project }}"
          branch: "plugin/${{ github.event.inputs.project }}"
          title: "[REPO] Add plugin ${{ github.event.inputs.project }}"
          body: |
            Automated PR to add the plugin ${{ github.event.inputs.project }}.
            You need to check this manually!
          labels: |
            plugin
          assignees: |
            matmair
            ${{ github.event.inputs.author }}
          reviewers: |
            matmair
