Skip to content

Commit

Permalink
Improve logging in set-milestone workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
hashhar committed Nov 21, 2022
1 parent 044092e commit f6510d4
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions .github/workflows/milestone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,26 @@ jobs:
commit_sha: context.sha
})
if (pr_response.data.length === 0) {
console.log('Pull request not found')
console.log('Pull request not found for commit', context.sha)
return
}
if (pr_response.data.length > 1) {
console.log(pr_response.data)
throw 'Expect 1 pull request but found: ' + pr_response.data.length
throw 'Expected 1 pull request but found: ' + pr_response.data.length
}
const pr_number = pr_response.data[0].number
console.log('Found pull request', pr_number, 'for commit', context.sha)
// Get milestone
const {
MILESTONE_NUMBER
} = 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)
console.log('Found milestone with title', MILESTONE_NUMBER, milestone)
// Create new milestone if it doesn't exist
if (!milestone) {
Expand All @@ -59,12 +63,14 @@ jobs:
title: MILESTONE_NUMBER
})
milestone = create_response.data
console.log('Created new milestone with title', MILESTONE_NUMBER, milestone)
}
// Set milestone to PR
await github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
milestone: milestone.number,
issue_number: pr_response.data[0].number
issue_number: pr_number
})
console.log('Added PR', pr_number, 'to milestone', MILESTONE_NUMBER)

0 comments on commit f6510d4

Please sign in to comment.