Sometimes a GitHub status check fails and you want to override it so you can still merge your PR. This is easiest to do with the GitHub CLI.
Your first step is to checkout your PR branch.
Get Information About the Status of Your Current Branch
gh api "repos/{owner}/{repo}/commits/{branch}/status" --jq '{ state: .state, sha: .sha, statuses: .statuses }'
Set a “success” status for the Current Branch
gh api --method POST \
"repos/{owner}/{repo}/statuses/$(git rev-parse HEAD)" \
-f state='success' \
-f description='Manually added success!'
(note: context is default by default, we can set it to something else with -f context='example-of-different-context-value')
Without Using gh CLI
curl --verbose -X POST \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer $GH_TOKEN" \
-d '{"state":"success","description":"Manually added success"}' \
https://api.github.com/repos/salcode/my-repo/statuses/$(git rev-parse HEAD)
Notes:
- You’ll need to replace
salcode/my-repowith the relevant GitHub account and repo values. - You’ll need to set the environment variable
GH_TOKENto be set to your GitHub personal access token.
Relevant Reading:
- GitHub Documentation on REST API for commit statuses
Leave a Reply