When publishing a GitHub page for a repo, the deploy action might fail with an HTTP-400 error:
Failed to create deployment (status: 400) with build version <build version hash>.
Responded with: Deployment request failed for <build version hash> due to in progress deployment.
Please cancel <deployment hash> first or wait for it to complete.
Based on a (now apparently defunct) community discussion thread. Another (still working) discussion of the same issue.
List deployments for the repo:
curl -u "<username>:<password or API key>" -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/<username>/<reponame>/deployments
Find the one that where the attribute sha
matches the <deployment hash>
mentioned in the deploy action's error message.
Make a (mental) note of the
url
attribute of that deployment (needed in step 3).
check the status of the deployment by opening the statuses_url
, there's probably an "in progress" entry
delete the offending deployment:
curl -u "<username>:<password or API key>" -H "Accept: application/vnd.github.v3+json" -X DELETE <deployment URL>
maybe wait a minute or two, then re-start the "pages build and deployment" workflow
-
according to a comment by @easrng, you might also need to cancel the pages deployment:
curl -u "<username>:<password or API key>" -H "Accept: application/vnd.github.v3+json" -X POST https://api.github.com/repos/<username>/<reponame>/pages/deployments/<deployment hash>/cancel
-
for more info regarding the relevant ReST API endpoints, see the GitHub API documentation, e.g. regarding Deployments and Pages.
-
for API authentication, instead of the
... -u "<username>:<password or API key>" ...
part, it is also possible to use... -H "Authorization: Bearer <access token>" ...
, using an access token with the required permissions (see API docs for required permissions). This is also the way shown in the examples in the API docs
Thanks for the tip 👍
I've updated the Gist accordingly