name: Create Pull Request

on:
  push:
    tags:
      - '\d+\.\d+\.\d+'
      - '\d+\.\d+'

jobs:
  create-pull-request:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v2
      - name: Generate pull request body
        id: pr
        run: |
          echo "docs/changelog/${{ github.ref }}.md"
      - name: Create Pull Request
        uses: peter-evans/create-pull-request@v3
        with:
          token: ${{ secrets.ACCESS_TOKEN }}
          commit-message: 'chore: release ${{ github.ref }}'
          title: 'chore: release ${{ github.ref }}'
          body: |
            ${{ steps.pr.outputs.body }}
          branch: release/${{ github.ref }}
          base: main
          labels: release
          draft: false
          branch-suffix: timestamp
          delete-branch: false