Skip to content

Conversation

@qurle
Copy link

@qurle qurle commented Feb 22, 2025

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
Should be red

Okay production:
https://badge.qurle.net/api/qurle/vercel-badge
Should be green

@vercel
Copy link

vercel bot commented Feb 22, 2025

@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.

Copy link
Owner

@datejer datejer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
(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`, {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants