name: milestones
on:
  pull_request:
    types:
      - closed

permissions:
  issues: 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@v3
      - 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,dependencies'
          minor-labels: 'feat'
          major-labels: 'breaking change'
          fallback: 'minor'
      - name: Show milestone
        run: echo "Assigned milestone is ${{ steps.assign-milestone.outputs.milestone }}"
