refactor!: Single type/alias for intersection status #91
Workflow file for this run
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: Check PR milestone | |
on: | |
pull_request_target: | |
types: [milestoned, demilestoned, opened, reopened] | |
branches: | |
- main | |
jobs: | |
check_milestone: | |
if: ${{ github.event.issue.pull_request || github.event.pull_request }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: "Check for milestone on PR" | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
let milestone = context.payload.pull_request.milestone; | |
if(context.payload.action === 'opened' || context.payload.action === 'reopened') { | |
if(milestone !== null) { | |
core.notice(`Milestone is ${milestone.title}`); | |
} else { | |
const milestones = await github.rest.issues.listMilestones({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
state: "open" | |
}); | |
for (const default_milestone of milestones.data) { | |
if (default_milestone.title === "next") { | |
core.notice(`No milestone set, setting default milestone: ${default_milestone.title}`); | |
await github.rest.issues.update({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: context.issue.number, | |
milestone: default_milestone.number | |
}); | |
return; | |
} | |
} | |
core.warning("Could not find default milestone named 'next'"); | |
} | |
} | |
else { | |
if(milestone !== null) { | |
core.notice(`Milestone is ${milestone.title}`); | |
} else { | |
core.setFailed("No milestone: Please add a version milestone"); | |
} | |
} |