name: Milestones
on:
  pull_request_target:
    types:
      - closed

permissions:
  issues: write
  pull-requests: write

jobs:
  milestone_job:
    if: github.event.pull_request.merged == true
    runs-on: ubuntu-latest
    name: Assign milestones to PRs
    steps:
      - name: Checkout code
        uses: actions/checkout@v4
      - name: Assign milestone to PR
        uses: srebhan/label-milestone-action@v1.0.1
        id: assign-milestone
        with:
          repo-token: ${{ secrets.GITHUB_TOKEN }}
          bugfix-labels: 'fix,chore,docs,test'
          minor-labels: 'feat'
          major-labels: 'breaking change'
          fallback: 'minor'
      - name: Show milestone
        run: echo "Assigned milestone is ${{ steps.assign-milestone.outputs.milestone }}"
