OSS-Docs-Tools / code-owner-self-merge

A GitHub Action for letting CODEOWNERS merge PRs via green PR reviews
MIT License
53 stars 16 forks source link

Fix green status check always failing when it has statuses #19

Closed diogotcorreia closed 3 years ago

diogotcorreia commented 3 years ago

When there is a deployment/code checking/etc, the GitHub API returns an array with the timeline. That means, even if a status has state success now, there is still an object in the array that has the state pending.

As an example, take a look at this API response from this PR.

This PR adds a filter to the array that removes duplicate statuses, keeping only the last ones (e.g. the ones at the beginning of the array). JSON objects are compared by the target_url property since that's unique and is the only thing that doesn't change between the status update.

This has been tested in the PR linked above.

orta commented 3 years ago

Thanks for the explanation, took me a while to get my head around so I added a comment - I think this is good to go 👍🏻