Surface staging/production commit drift on the infra dashboard
- Dominant language
- TypeScript
- Stars
- 3
- Forks
- 9
- Avg merge
- 4d 14h
- Merged PRs (30d)
- 6
Description
## Description
There's no way to see how far the deployed environments lag `main` without manually comparing commits. We want the infra dashboard ([618457](https://telemetry.betterstack.com/team/t468215/dashboards/618457)) to show, at a glance, how many commits staging and production are behind `main`, plus each environment's current commit, so the drift spotcheck becomes self-service.
## Proposed approach
Do the git math at build time and let BetterStack do the subtraction. BetterStack already scrapes `/metrics`, so no exporter or external service is needed.
1. At image build, compute commit height with `git rev-list --count HEAD` and bake it into the image alongside the commit SHA and version.
2. Emit Prometheus gauges from the backend:
- `dealbot_build_commit_height` (integer height)
- `dealbot_build_info{commit, version}` (info metric, value `1`)
- optionally `dealbot_build_commit_timestamp` for a "time behind" readout
3. On the dashboard, a metric expression `height{env="staging"} - height{env="production"}` gives the exact commits production is behind. Display each env's `commit` as a `github.com/.../commit/` link.
This is exact because every push to `main` deploys to staging and production is a release-please promotion of an older `main` commit, so production is always an ancestor of `main` on a linear squash history. Height delta equals commit count.
## Implementation notes
- The `env` label (`staging`/`production`) must come from runtime config, not the image. Production reuses the staging-built image via retag ([release-please.yml](https://github.com/FilOzone/dealbot/blob/main/.github/workflows/release-please.yml)), so a baked-in label would be wrong.
- `actions/checkout` defaults to a shallow clone; set `fetch-depth: 0` so `rev-list --count` sees full history.
## Definition of done
- Dashboard 618457 shows commits-behind for staging and production and a clickable current-commit link per env.
- The number is verified against a known deploy (e.g. production N commits behind staging matches `git rev-list --count`).
Context: [Slack thread](https://filecoinproject.slack.com/archives/C08TVNKJV7C/p1773619208897229?thread_ts=1773508200.474589&cid=C08TVNKJV7C)
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.