git-for-windows / gfw-helper-github-app

2 stars 6 forks source link

After a Git for Windows version has been released, automatically close the corresponding PR #66

Closed dscho closed 8 months ago

dscho commented 8 months ago

I outlined the idea here. The gist is:

Let's listen for completed release-git workflow runs in the git-for-windows-automation repository. The trick is to get from that workflow run to the corresponding git-for-windows/git PR because there is no information in the Get a Check Run response to get back to the git-for-windows/git PR or tag or commit (example: https://api.github.com/repos/git-for-windows/git-for-windows-automation/actions/runs/7978659901).

Sadly, searching for a PR comment containing the workflow run ID won't work because the REST API search endpoint searches the rendered text, not the Markdown. But we can search for an open PR with the comment and then follow the comments_url (e.g. https://api.github.com/repos/git-for-windows/git/issues/4828/comments) that does have that link and has author_association == 'MEMBER' (which we need to verify so that we don't fall for jokers who open bogus PRs and add a comment of the exact correct format to throw the automation). By filtering the search results thusly, we should end up with a single candidate for the PR to close.

Finally, retrieve the necessary information from the PR and then use the repos/.../git/refs/main endpoint endpoint (with force=false, to avoid accidental force-pushing). This "pushes" the PR branch to main, thereby closing the PR.

My plan is to verify this with the Git for Windows v2.44.0 release that's expected to happen tomorrow.

dscho commented 8 months ago

auto-push-main-failed

😞

dscho commented 8 months ago

Hopefully https://github.com/git-for-windows/gfw-helper-github-app/commit/0896eab07dadf6ef698471a0ac8ad554f1669cc0 fixes it. I'll click the Redeliver button once the deployment finished.

dscho commented 8 months ago

auto-push-main-succeeded

🎉