This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Assign Milestone on Close | ||
env: | ||
MILESTONE_ID: 1 | ||
on: | ||
issues: | ||
types: [closed] | ||
pull_request: | ||
types: [closed] | ||
jobs: | ||
assign-milestone: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check if milestone is set | ||
id: check-milestone | ||
uses: actions/github-script@v7 | ||
outputs: | ||
Check failure on line 19 in .github/workflows/assign-milestone-on-close.yml GitHub Actions / Assign Milestone on CloseInvalid workflow file
|
||
milestoneNotSet: ${{ steps.check-milestone.outputs.milestoneNotSet }} | ||
with: | ||
github-token: ${{secrets.GITHUB_TOKEN}} | ||
script: | | ||
const issueOrPr = context.payload.issue || context.payload.pull_request; | ||
if (!issueOrPr.milestone) { | ||
core.setOutput('milestoneNotSet', 'true'); | ||
} | ||
core.setOutput('milestoneNotSet', 'false'); | ||
- name: Assign default milestone | ||
if: steps.check-milestone.outputs.milestoneNotSet == 'true' | ||
uses: actions/github-script@v7 | ||
with: | ||
github-token: ${{secrets.GITHUB_TOKEN}} | ||
script: | | ||
const issueOrPrNumber = (context.payload.issue || context.payload.pull_request).number; | ||
const repository = context.repo; | ||
await github.rest.issues.update({ | ||
...repository, | ||
issue_number: issueOrPrNumber, | ||
milestone: process.env.MILESTONE_ID | ||
}); |