Badge: per-environment deployment badge (deployed version/status)
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 7
- Forks
- 3
- Avg merge
- 2h 12m
- Merged PRs (30d)
- 30
Description
Problem
Status badges (#292) reflect run/build status. But "did CI pass" and "what's actually deployed" are different questions — and in gocdnext deployment is not a run event: it's a stage/gate inside a pipeline (approval → deploy job), and the authoritative state lives in deployment_revisions/environments, not runs.cause. A user who holds a manual prod-approval gate sees the build badge sit at running while nothing is actually building.
A deployment badge answers the CD question directly: what version is live in environment X.
Proposal
A per-environment deployment badge:
GET /api/v1/badge/{slug}/env/{environment}.svg?token=T
- label = the environment name (
production,stage). - message = the currently-deployed version (e.g.
10.1.19-abc), or a status word (deployed/pending/failed) when no version string is recorded. - Reads the latest
deployment_revisionsrow for(project, environment).



Scope
- New route + store query: latest deployment revision per
(project_id, environment), gated by the samebadge_token_hashas #292 (one token, multiple views). - Render: variable-width message (the version string) — the current renderer already
html.EscapeStrings everything; add a length cap (~32–48 chars + ellipsis) so a pathological version can't blow up the SVG. - Docs: badge reference page.
Guardrails (security / performance / corner cases)
- New reflection surface: unlike the build badge (fixed status enum), this reflects the version string into the SVG. Keep
html.EscapeString+ add a hard length cap; the version is already validated on the deploy path (deploy.versionallow-list), but cap defensively anyway. - Disclosure: exposes the deployed version (slightly more than pass/fail) — same sensitivity class, opt-in, coarse; fine for the same audience that can already see the build badge.
- No oracle: unknown env / no deployment / bad token → the same
unknownbadge. - Perf: indexed lookup of the latest revision per
(project, environment);EXPLAIN ANALYZEin the PR.
Depends on / relates to
Builds on the #292 token/render/cache infra. Complementary to (not blocked by) the ?event= filter issue.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the existing #292 badge token, render, and cache infrastructure, then trace the badge route and renderer. Inspect deployment_revisions and environments for the latest per-project environment lookup, and update the badge reference page; done means the new route returns the version or fallback status, uses the shared token, caps and escapes the message, and supports the documented cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- api, backend, database, documentation
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100