Delete or cancel commit status

Why it is impossible to delete commit status? Or at least set its status to completed or canceled?

I’m referring to Status API NOT Checks https://developer.github.com/v3/repos/statuses/

You could use the values  error  and  success instead of canceled  and  completed  and maybe the best would be to not send the status until you have a definitive value. So instead of sending a first  pending  status and then updating it, just send the status once the job is completed with its definitive value, if needed. 

I just came across a similar scenario … I created a status via the API as mentioned in the docs:

https://developer.github.com/v3/repos/statuses/

But now I want to delete it from the repo such that it no longer appears under the branch protection rules as a selection. Even when not ‘required’ the status appears in the user’s PR, and it is confusing to them. I do not see any way to remove it via the API however. Is there a corresponding ‘DELETE’ action to remove it for example? (have not tried it yet)

It’s possible to push a new commit status with an existing context, which will have the effect of changing the check’s status in the GitHub UI. See: https://webapps.stackexchange.com/a/78518/17972

Code to do this using @octokit/rest v16 (latest as of this writing):

octokit.repos.createStatus( {
    owner : 'username',
    repo : 'reponame',
    sha : 'commithash',
    context : 'continuous-integration/travis-ci/push',
    state : 'success',
    target_url : 'https://your.url/',
    description : 'The Travis CI build status was overwritten by a script',
} ).then( result => {
    console.log( 'Updated build status:', result.status );
} );