Support Now CI badge
See original GitHub issueIt might sounds crazy, but it’s truly beautiful to use it as CI/CD 😄
How?
now.json
{
"version": 2,
"name": "tunnckocore-template",
"builds": [{ "src": "package.json", "use": "@now/static-build" }]
}
and define now-build
script
"scripts": {
"lint": "yarn scripts devest lint",
"test": "yarn scripts devest test",
"build": "yarn scripts pika-pack build --out dist",
"status:pass": "badgen --subject build --status passing --color green > dist/badge.svg",
"status:fail": "badgen --subject build --status failing --color red > dist/badge.svg",
"pkg": "yarn lint && yarn test && yarn build",
"now-build": "(yarn pkg && yarn status:pass) || yarn status:fail"
},
The thing is, that when build fails, it actually doesn’t publish the contents of dist/
so we can’t just get the generated failing
badge. For now I can just point the badge to https://<myrepo>.<my-zeit-username>.now.sh/badge.svg
So, the alternatively we can have it here, and query directly the API with https://zeit.co/docs/api#endpoints/deployments/list-deployments and get the first item from the We’ll need the deployment “name” and fitler by it and after that get the first item. But, sadly, the API endpoint wants a token, which might be a problem, because we also have some rate limits there. But we have caching here, right? So it won’t be a problem?data.deployments[0].state
I can PR, but we’ll need to add a token to the secrets.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:26 (26 by maintainers)
Top GitHub Comments
That’s brilliant, almost worked 😂
+1 on the github way
Just realize that we already have the combined status badge 😂 with exactly this schema: