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.
I outlined the idea here. The gist is:
Let's listen for completed
release-git
workflow runs in thegit-for-windows-automation
repository. The trick is to get from that workflow run to the correspondinggit-for-windows/git
PR because there is no information in the Get a Check Run response to get back to thegit-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 hasauthor_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 (withforce=false
, to avoid accidental force-pushing). This "pushes" the PR branch tomain
, 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.