GHA to ensure milestone #1
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 if pull request is milestoned | |
on: | |
pull_request: | |
types: [opened, edited, milestoned, demilestoned] | |
jobs: | |
check_milestone: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check milestone | |
uses: actions/github-script@v5 | |
with: | |
github-token: ${{secrets.GITHUB_TOKEN}} | |
script: | | |
const { data: pullRequest } = await github.rest.pulls.get({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
pull_number: context.issue.number | |
}); | |
if (!pullRequest.milestone) { | |
throw new Error('Pull request does not have a milestone. Please add a milestone.'); | |
} | |
console.log('Pull request has a milestone.'); |