Skip to content

Commit

Permalink
Create check_milestone.yml
Browse files Browse the repository at this point in the history
[ci skip]
  • Loading branch information
pllim committed Feb 22, 2024
1 parent a2218c6 commit 9f5f57d
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/check_milestone.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Check PR milestone

on:
# So it cannot be skipped.
pull_request_target:
types: [opened, synchronize, milestoned, demilestoned]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read

jobs:
# https://stackoverflow.com/questions/69434370/how-can-i-get-the-latest-pr-data-specifically-milestones-when-running-yaml-jobs
milestone_checker:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v7
if: github.repository == 'astropy/sphinx-automodapi'
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { data } = await github.request("GET /repos/{owner}/{repo}/pulls/{pr}", {
owner: context.repo.owner,
repo: context.repo.repo,
pr: context.payload.pull_request.number
});
if (data.milestone) {
core.info(`This pull request has a milestone set: ${data.milestone.title}`);
} else {
core.setFailed(`A maintainer needs to set the milestone for this pull request.`);
}

0 comments on commit 9f5f57d

Please sign in to comment.