Skip to content

Commit

Permalink
Fix set-milestone failure when latest milestone is closed
Browse files Browse the repository at this point in the history
There can be situation where the latest milestone is closed but there
are still some PRs for which this workflow is pending. The  API by
default only lists open milestones. This commit changes it to list all
milestones so that even if the target milestone is closed it can be
found and the PR added to it.

This is correct reimplementation of
c38490b.
  • Loading branch information
hashhar committed Nov 21, 2022
1 parent f6510d4 commit 5a8220c
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions .github/workflows/milestone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,14 @@ jobs:
} = process.env
console.log('Milestone number to set', MILESTONE_NUMBER)
// Find milestone
const response = await github.rest.issues.listMilestones(context.repo)
let milestone = response.data.find(milestoneResponse => milestoneResponse.title === MILESTONE_NUMBER)
// Find milestone with matching title
// See https://octokit.github.io/rest.js/v19#pagination
const milestones = await github.paginate(github.rest.issues.listMilestones, {
owner: context.repo.owner,
repo: context.repo.repo,
state: 'all'
})
let milestone = milestones.find(milestone => milestone.title === MILESTONE_NUMBER)
console.log('Found milestone with title', MILESTONE_NUMBER, milestone)
// Create new milestone if it doesn't exist
Expand Down

0 comments on commit 5a8220c

Please sign in to comment.