Skip to content

Inject COMMIT_SHA and BUILD_DATE at build time for /api/version #396

@tbrandenburg

Description

@tbrandenburg

Background

The `/api/version` endpoint (added in #300) returns `commit_sha` and `build_date` fields, but they currently always return `"unknown"` because no build-time injection is in place:

```python
"commit_sha": os.environ.get("COMMIT_SHA", "unknown"),
"build_date": os.environ.get("BUILD_DATE", "unknown"),
```

Problem

Without CI/CD injecting these values, operators cannot use `/api/version` to verify which exact commit is running in an environment — defeating part of the feature's operational value.

Proposed Solution

Inject `COMMIT_SHA` and `BUILD_DATE` as environment variables during CI/CD pipeline execution (e.g. GitHub Actions):

```yaml
env:
COMMIT_SHA: ${{ github.sha }}
BUILD_DATE: ${{ github.event.head_commit.timestamp }}
```

For Docker deployments, pass them as build args or runtime env vars.

Acceptance Criteria

  • `GET /api/version` returns the actual git SHA (not `"unknown"`) when running in CI/CD-deployed environments
  • `GET /api/version` returns the actual build date when running in CI/CD-deployed environments
  • Local development can still return `"unknown"` gracefully

Related

Deferred from #300 (explicitly out of scope for that PR).

Metadata

Metadata

Assignees

No one assigned

    Labels

    complexity/lowLow complexity - straightforward implementationconfidence/highHigh confidence - well understood, low risk of issuesenhancementNew feature or requestopenNew or unrefined work. Collaborative grooming allowed.priority/mediumNormal priority - standard workflowseverity/mediumMedium severity - limited impact or workaround exists

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions