name: 🎯 Assign milestone # Automatically assigns a milestone to PRs based on their conventional-commit # title. This is NOT a required check - the required "🚩 Require milestone" # check lives in require-milestone.yml, which also explains why the check and # the assignment are split into two single-trigger workflows with different # check names. # # We must use pull_request_target here because assigning a milestone needs a # write-capable GITHUB_TOKEN, and fork PRs get a read-only token under # pull_request regardless of declared permissions. # # Using pull_request_target can be dangerous as it allows fork PRs to trigger # a workflow run with a write-capable GITHUB_TOKEN. The safety of this # workflow depends on two things: # 1. It never checks out the fork's merge ref (refs/pull/.../merge). Under # pull_request_target, both the workflow definition and the checkout # step's default ref come from the base branch. # 2. It never executes fork-controlled code. The assign-milestone action # only reads PR metadata and calls the GitHub API. # This also means changes to this workflow and to the assign-milestone action # only take effect once they land on the base branch. # # No `milestoned` trigger type: when a milestone was just added there's # nothing left to assign. on: pull_request_target: types: [opened, synchronize, reopened, demilestoned, edited] # Cancel in-progress runs of this workflow. # See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-only-cancel-in-progress-jobs-or-runs-for-the-current-workflow. concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number }} cancel-in-progress: true # No top level permissions are required for this workflow permissions: {} jobs: assign-milestone: name: 🎯 Assign milestone runs-on: ubuntu-latest permissions: # The narrowest permission needed for the milestone API call pull-requests: write steps: # Checks out the base branch, NOT the PR's code. See the security notes # at the top of this file before changing this step. - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 - name: ⬢ Set up Node.js uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6 with: node-version: 24 - name: 🎯 Assign milestone uses: ./.github/actions/assign-milestone with: github-token: ${{ secrets.GITHUB_TOKEN }}