Skip to content

Commit

Permalink
Merge pull request #19 from diogotcorreia/green-status-fix
Browse files Browse the repository at this point in the history
Fix green status check always failing when it has statuses
  • Loading branch information
orta committed Apr 5, 2021
2 parents 7620005 + edda14d commit 8afed65
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,13 @@ async function mergeIfLGTMAndHasAccess() {

// Don't merge red PRs
const statusInfo = await octokit.repos.listCommitStatusesForRef({ ...thisRepo, ref: prInfo.data.head.sha })
const failedStatus = statusInfo.data.find(s => s.state !== "success")
const failedStatus = statusInfo.data
// Check only the most recent for a set of duplicated statuses
.filter(
(thing, index, self) =>
index === self.findIndex((t) => t.target_url === thing.target_url)
)
.find(s => s.state !== "success")

if (failedStatus) {
await octokit.issues.createComment({ ...thisRepo, issue_number: issue.number, body: `Sorry @${sender}, this PR could not be merged because it wasn't green. Blocked by [${failedStatus.context}](${failedStatus.target_url}): '${failedStatus.description}'.` });
Expand Down

0 comments on commit 8afed65

Please sign in to comment.