Use only production deployments by default#4
Conversation
|
@qurle is attempting to deploy a commit to the Artur Dudek's projects Team on Vercel. A member of the Team first needs to authorize it. |
datejer
left a comment
There was a problem hiding this comment.
Hey! Thanks for the PR and sorry for such a late response, GitHub notifications are such a mess that I never notice these kinds of things.
Not sure if the GitHub API schema changed in the time it took for me to get to it, but I believe the environment should be lowercase?
https://docs.github.com/en/rest/deployments/deployments?apiVersion=2022-11-28#list-deployments
| deployment.creator.html_url === "https://github.com/apps/vercel" && | ||
| deployment.creator.type === "Bot" | ||
| deployment.creator.type === "Bot" && | ||
| (previews === "true" || deployment.environment === "Production") |
There was a problem hiding this comment.
| (previews === "true" || deployment.environment === "Production") | |
| (previews === "true" || deployment.environment === "production") |
| else previews = req.query.previews; | ||
|
|
||
| axios | ||
| .get(`https://api.github.com/repos/${owner}/${repo}/deployments`, { |
There was a problem hiding this comment.
Also I believe this could be done more properly, using the query parameters in the request itself instead of filtering the response, i.e. https://api.github.com/repos/${owner}/${repo}/deployments?environment=production, to avoid issues like having the last production deployment be outside of the currently returned page.
Hi Artur,
By default you use show the status of the last deployment. If it’s a failed preview, that’s usually okay for the project.
In this PR I excluded preview deployments from the badge by default. Now the badge show status of the last production deployment. I also added and documented query parameter to include preview developments.
Example

Failed preview:
https://badge.qurle.net/api/qurle/vercel-badge?previews=true
Okay production:

https://badge.qurle.net/api/qurle/vercel-badge