sounisi5011/metalsmith-netlify-published-date

Exclude failed deploy

Closed this issue · 1 comments

Deployment of Netlify may fail due to a build command execution error.
However, the API also includes failed deployments in the response.

Here is an example of a response that is included if it fails:

[
  {
    "id": "5d373429fe86c30007046283",
    "site_id": "572182f8-cd03-4a65-a9f2-c652cef692e0",
    "build_id": "5d373429fe86c30007046284",
    "state": "error",
    "name": "blissful-pike-6bfd0f",
    "url": "http://blissful-pike-6bfd0f.netlify.com",
    "admin_url": "https://app.netlify.com/sites/blissful-pike-6bfd0f",
    "deploy_url": "http://deploy-preview-17.blissful-pike-6bfd0f.netlify.com",
    "deploy_ssl_url": "https://deploy-preview-17--blissful-pike-6bfd0f.netlify.com",
    "created_at": "2019-07-23T16:22:01.496Z",
    "updated_at": "2019-07-23T16:22:18.451Z",
    "commit_ref": "befeef1564f05585a168d00f3679047425004d1b",
    "review_id": 17,
    "skipped": null,
    "locked": null,
    "branch": "add-example",
    "commit_url": "https://github.com/sounisi5011/metalsmith-netlify-published-date/commit/befeef1564f05585a168d00f3679047425004d1b",
    "log_access_attributes": {
      "type": "firebase",
      "url": "https://netlify-builds1.firebaseio.com/builds/5d373429fe86c30007046284/log",
      "endpoint": "https://netlify-builds1.firebaseio.com",
      "path": "/builds/5d373429fe86c30007046284/log",
      "token": "VAPDSU7Mfqv7zWMcFPW3lsHfS912n5oh3SrgKTBt"
    },
    "title": "[WIP] Add example",
    "review_url": "https://github.com/sounisi5011/metalsmith-netlify-published-date/pull/17",
    "published_at": null,
    "context": "deploy-preview",
    "deploy_time": null,
    "public": true,
    "summary": {
      "status": "unavailable",
      "messages": []
    }
  }
]

Because this deployment failed, there is no preview.
The URL where the preview should exist returns 404 Not Found.
If such a deployment is included in the search target of the published date, the preview immediately after the deployment failure will be judged incorrectly as the published date of the Web page.

Failed Deploy Differences:

  • The value of the /state field is "error" instead of "ready"
  • The value of the /summary/status field is "unavailable" instead of "ready"