Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 124 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -566,3 +566,127 @@ jobs:
if [ -n "$TAG" ]; then TAG_ARGS+=(--tag "$TAG"); fi
done <<< "$TAGS"
docker buildx imagetools create "${TAG_ARGS[@]}" "${RUNNER_IMAGE}@${DIGEST}"

mcp-server-image:
name: Build & Publish MCP Server Image
needs: release-please
# It builds, smoke-tests, scans, pushes by digest and attests the mcp-server image of the
# release, then tags it with the release tag and latest; Image Updater rolls Deployment
# mcp-server onto the new digest (#4324). The package is new: a person sets it public once, so
# the pod pulls it with no credential (see the pull request of #4324).
if: needs.release-please.outputs.release_created == 'true'
runs-on: ubuntu-26.04
timeout-minutes: 30
permissions:
contents: read
packages: write
id-token: write
attestations: write
env:
MCP_SERVER_IMAGE: ghcr.io/${{ github.repository }}/mcp-server

steps:
- name: Check out repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
# The commit that the release tags: a later push can start the run that creates it.
ref: ${{ needs.release-please.outputs.sha }}
persist-credentials: false

- name: Log in to GitHub Container Registry (GHCR)
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v3

- name: Extract Metadata for MCP Server Image
id: meta
uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0
with:
images: ${{ env.MCP_SERVER_IMAGE }}
tags: |
type=raw,value=${{ needs.release-please.outputs.tag_name }}
type=raw,value=latest
labels: |
org.opencontainers.image.title=devops-cli-mcp-server
org.opencontainers.image.description=DevOps CLI MCP server that serves role-scoped tool sets to cluster jobs
org.opencontainers.image.licenses=MIT
org.opencontainers.image.documentation=https://github.com/dan-petty/devops-cli/blob/main/README.md
org.opencontainers.image.source=https://github.com/dan-petty/devops-cli
org.opencontainers.image.version=${{ needs.release-please.outputs.tag_name }}

- name: Build and Load MCP Server Image
uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v6
with:
context: .
file: ./Dockerfile
target: mcp-server
load: true
push: false
tags: devops-cli-mcp-server:local
no-cache-filters: mcp-server
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Run MCP Server Image Smoke Test
env:
IMAGE: devops-cli-mcp-server:local
run: |
docker run --rm --entrypoint id "$IMAGE" -u
docker run --rm "$IMAGE" --version
docker run --rm -e DEVOPS_CLI_USER_DATA_ROOT=/opt/devops-tools --entrypoint devops "$IMAGE" install-tools --check --tool kubectl --target-dir /opt/devops-tools/bin
docker run --rm -e DEVOPS_CLI_USER_DATA_ROOT=/opt/devops-tools --entrypoint devops "$IMAGE" install-tools --check --tool helm --target-dir /opt/devops-tools/bin
size=$(docker image inspect "$IMAGE" --format '{{.Size}}')
if [ "$size" -gt 3000000000 ]; then echo "The mcp-server image is $size bytes, over the bound of 3000000000."; exit 1; fi

- name: Scan MCP Server Image for Vulnerabilities
uses: aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25 # v0.36.0
with:
image-ref: devops-cli-mcp-server:local
scanners: vuln
severity: HIGH,CRITICAL
ignore-unfixed: true
trivyignores: .trivyignore,.trivyignore-mcp-server
exit-code: "1"
version: v0.75.0

# Pushed by digest only: the tags move to the digest once its provenance is attested, so
# a tag never names an unattested image and a failed attestation is retried by a re-run.
- name: Build and Push MCP Server Image
id: push
uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v6
with:
context: .
file: ./Dockerfile
target: mcp-server
platforms: linux/amd64
outputs: type=image,name=${{ env.MCP_SERVER_IMAGE }},push-by-digest=true,name-canonical=true,push=true
labels: ${{ steps.meta.outputs.labels }}
sbom: true
no-cache-filters: mcp-server
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Attest Build Provenance
uses: actions/attest-build-provenance@9d57eef8c06cd9d6b433effeeb7a6a77b3ff94ad # v2
with:
subject-name: ghcr.io/${{ github.repository }}/mcp-server
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true

- name: Tag the Attested MCP Server Image
id: tag
shell: bash
env:
DIGEST: ${{ steps.push.outputs.digest }}
TAGS: ${{ steps.meta.outputs.tags }}
run: |
TAG_ARGS=()
while read -r TAG; do
if [ -n "$TAG" ]; then TAG_ARGS+=(--tag "$TAG"); fi
done <<< "$TAGS"
docker buildx imagetools create "${TAG_ARGS[@]}" "${MCP_SERVER_IMAGE}@${DIGEST}"
3 changes: 2 additions & 1 deletion RELEASE_CYCLE.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ The `Release` run of the merge creates the GitHub release and its tag. Then thes
| `Build DevContainer Image`, `Smoke-Test DevContainer Image`, `Attest & Tag DevContainer Image` | `ghcr.io/dan-petty/devops-cli/devcontainer`, tagged with the release tag and `latest` |
| `Build & Publish Service Image` | `ghcr.io/dan-petty/devops-cli/service`, tagged with the release tag and `latest` |
| `Build & Publish Runner Image` | `ghcr.io/dan-petty/devops-cli/runner`, the image of the implement Job, tagged with the release tag and `latest` |
| `Build & Publish MCP Server Image` | `ghcr.io/dan-petty/devops-cli/mcp-server`, the image of Deployment `mcp-server`, tagged with the release tag and `latest` |

Argo CD Image Updater then moves the Service and the CronJob template of the runner onto the new image digests ([`k8s/README.md`](k8s/README.md), Service Image Updates).
Argo CD Image Updater then moves the Service, the CronJob template of the runner and Deployment `mcp-server` onto the new image digests ([`k8s/README.md`](k8s/README.md), Service Image Updates).

## When a Publish Job Fails

Expand Down
2 changes: 1 addition & 1 deletion k8s/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1153,7 +1153,7 @@ devops k8s deploy-stack --stack devops

### Service Image Updates

Application `argocd-image-updater` runs [Argo CD Image Updater](https://argocd-image-updater.readthedocs.io/en/stable/) in namespace `argocd`, from the argo-helm chart pinned to a version like the other chart Applications. Its one ImageUpdater, `devops` in `k8s/argocd/image-updater-values.yaml`, keeps the `devops` Application on the digests that `ghcr.io/dan-petty/devops-cli/service:latest` and `ghcr.io/dan-petty/devops-cli/runner:latest` point at. The text below describes the Service image; the runner image of CronJob `devops-cli-runner` is handled in the same way:
Application `argocd-image-updater` runs [Argo CD Image Updater](https://argocd-image-updater.readthedocs.io/en/stable/) in namespace `argocd`, from the argo-helm chart pinned to a version like the other chart Applications. Its one ImageUpdater, `devops` in `k8s/argocd/image-updater-values.yaml`, keeps the `devops` Application on the digests that `ghcr.io/dan-petty/devops-cli/service:latest`, `ghcr.io/dan-petty/devops-cli/runner:latest` and `ghcr.io/dan-petty/devops-cli/mcp-server:latest` point at. The text below describes the Service image; the runner image of CronJob `devops-cli-runner` and the image of Deployment `mcp-server` are handled in the same way. The release publishes each of the three, and a test fails when a manifest names an image of this repository that no job of `release.yml` pushes (#4324). After the first release that publishes the MCP server image, a person makes the GHCR package `mcp-server` public, as the package `service` is, or the pod stays in `ImagePullBackOff`:

- Every two minutes it reads that digest. When the Application runs another one, it writes `ghcr.io/dan-petty/devops-cli/service:latest@sha256:<digest>` into the Application's `spec.source.kustomize.images`, and Argo CD rolls roadmap-service and CronJob `devops-cli` onto it. Git names the image untagged, and that entry sets its tag and digest.
- It updates the image also when no pod runs it, because the image sets `forceUpdate: true`. Without it, Image Updater updates only the images that a pod in the Application's tree runs, and no such pod runs this image: CronJob `devops-cli` is a suspended template, `roadmap-service` can be at 0 replicas, and the Jobs that `devops k8s run-job` starts are outside the tree. ImageUpdater `devops` then stays Ready with `imagesManaged: 0` and updates nothing. When the Application already names the digest, it writes nothing.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
schema: spec-driven
created: 2026-11-10
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Design

## Decisions
- **Copy the `runner-image` job.** It builds, scans, pushes by digest, attests, then tags. A tag never names an unattested image, and a failed attestation is retried by a re-run. The job needs `release-please` and runs only when `release_created` is `true`, like the other publish jobs.
- **One gate for CI and release.** The smoke test of the release equals the smoke test of `ci.yml`, and the release scan equals the CI scan, including `.trivyignore-mcp-server`. A test compares them. The image that is pushed passed what the pull request checked.
- **Tie the manifests to the publish jobs with a test.** The test reads each YAML file under `k8s/`, collects every value of the keys `image` and `imageName` that starts with `ghcr.io/dan-petty/devops-cli/`, and requires that a job of `release.yml` attests that name. It reads files only, so it needs no network and runs in the devcontainer and on the GitHub runner.
- **Keep the manifest.** The manifest follows the pin convention of the repository: no tag, and Image Updater writes the digest from `latest`. No digest in git can exist before a first publish.

## Rejected alternatives
- **Delete or disable Deployment `mcp-server`.** The roadmap Service and the runner Jobs need the server (#3221, #4191), and Argo CD would prune a deleted manifest. The image is the missing part.
- **Publish the image from `ci.yml` on `main`.** The other images publish at a release only, and a push on each merge would give the cluster an image that is not a release.
- **A reusable workflow for the three image jobs.** It is a larger change of pinned jobs and outside this issue.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Proposal: The Release Publishes the MCP Server Image (#4324)

## Why
Deployment `mcp-server` in namespace `devops` has been in `ImagePullBackOff` since it was created (2026-11-09T21:16Z). It names `ghcr.io/dan-petty/devops-cli/mcp-server`, and no workflow pushes that image. `release.yml` pushes `devcontainer`, `service` and `runner`. `ci.yml` job `mcp-server-image` (#3220) builds the target with `push: false`. Image Updater cannot find the package, so it writes no digest for it. Closes #4324.

## What Changes
- Add job `mcp-server-image` to `release.yml`. It follows job `runner-image`: build and load the `mcp-server` target, run the smoke test, scan, push by digest, attest, and tag with the release tag and `latest`.
- Run in the release the same smoke test and the same Trivy scan (with `.trivyignore-mcp-server`) as `ci.yml` job `mcp-server-image`. A test fails when the two differ.
- Add a test that fails when a manifest or an ImageUpdater under `k8s/` names `ghcr.io/dan-petty/devops-cli/<name>` and no job of `release.yml` attests `<name>`.
- Update `RELEASE_CYCLE.md` and `k8s/README.md` to list the new job and the person step.

The manifest `k8s/devops/mcp-server/deployment.yaml` does not change: it names the image with no tag, as the `service` and `runner` manifests do, and the entry `mcp-server` of the ImageUpdater already keeps the digest.

## Capabilities

### Modified Capabilities
- `mcp-server-image`: the release publishes the image, and a test ties each image of this repository in `k8s/` to a publish job.

## Impact
- `.github/workflows/release.yml` gains one job that runs only in the run that creates a release. No pull request check changes.
- A person makes the new GHCR package public once, after its first publish. Until then the pod cannot pull the image.
- The pod becomes Ready only after the first release that holds this job.

## Feasibility
Checked against the real system on 2026-11-10:
- `kubectl -n devops describe pod -l app.kubernetes.io/name=mcp-server`: `Back-off pulling image "ghcr.io/dan-petty/devops-cli/mcp-server"` (1296 times in 4h58m). Application `devops` is `Synced` and `Degraded`.
- `devops gh api /user/packages/container/devops-cli%2Fmcp-server/versions` returns 404, `Package not found`.
- The log of the Image Updater controller, every two minutes: `Could not get tags from registry: Get "https://ghcr.io/v2/dan-petty/devops-cli/mcp-server/tags/list": denied`. `spec.source.kustomize.images` of Application `devops` holds `service` and `runner` only.
- `release.yml` has no job that names `mcp-server`. `rg mcp-server .github/workflows` finds `ci.yml` only.
- `Dockerfile` stage `mcp-server` exists and `ci.yml` builds, smoke-tests and scans it on each pull request, so the release can reuse that gate.
- The deployment is wanted: #3220 added the image, #4182 deferred the manifests until the image existed, and #4275 added the manifests with the ImageUpdater entry. Nothing in them publishes the image. So the fix is the publish job, not a removal of the Deployment.

## Existing Tool Considered
The job uses the actions that the `service` and `runner` jobs already use (`docker/build-push-action`, `docker/metadata-action`, `aquasecurity/trivy-action`, `actions/attest-build-provenance`, `docker buildx imagetools`). A reusable workflow would remove the duplicate of the three image jobs, but it changes the pinned `service` and `runner` jobs, which is outside this issue. The cost of this job is one copy of 124 lines, about 15k tokens, which the test of the identical smoke test and scan keeps in step with `ci.yml`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
## Purpose
The container image target for the MCP server that serves role-scoped tool sets to cluster jobs.

## ADDED Requirements

### Requirement: The release publishes the MCP server image
The `release.yml` workflow SHALL build, smoke-test, scan, push by digest, attest and tag the `mcp-server` image, in that order, only in the run that creates a release. It SHALL tag the image with the release tag and `latest`.

#### Scenario: Publish job order
- **WHEN** A test reads job `mcp-server-image` of `release.yml`.
- **THEN** The job needs `release-please`, runs only when `release_created` is `true`, builds target `mcp-server`, pushes with `push-by-digest=true`, attests `ghcr.io/${{ github.repository }}/mcp-server`, and its steps keep the order of the `runner-image` job.

### Requirement: The release gate equals the pull request gate
The smoke test and the vulnerability scan of the release job SHALL equal those of job `mcp-server-image` in `ci.yml`.

#### Scenario: Same smoke test and scan
- **WHEN** A test compares the two jobs.
- **THEN** The smoke test scripts are equal and the inputs of the Trivy steps are equal.

### Requirement: Each image of this repository in k8s has a publish job
Each value of the keys `image` and `imageName` under `k8s/` that starts with `ghcr.io/dan-petty/devops-cli/` SHALL name an image that a job of `release.yml` attests.

#### Scenario: Manifest names an unpublished image
- **WHEN** A manifest under `k8s/` names `ghcr.io/dan-petty/devops-cli/<name>` and no job of `release.yml` attests `<name>`.
- **THEN** The test fails and names the image and the file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Tasks

## 1. Behavior

- [x] 1.1 Write the failing tests: the release job, the same smoke test and scan, and the check that each image in `k8s/` has a publish job
- Verification: `$ uv run devops ci fail-to-pass --base origin/main` shows the tests fail before the change and pass after it
- [x] 1.2 Add job `mcp-server-image` to `release.yml`
- Verification: `$ uv run devops ci test tests/invariants/test_mcp_server_image.py tests/invariants/test_workflow_contracts.py tests/invariants/test_k8s_manifests.py`

## 2. Documents

- [x] 2.1 List the job in `RELEASE_CYCLE.md` and the person step in `k8s/README.md`
- Verification: `$ uv run devops ci docs`
21 changes: 21 additions & 0 deletions openspec/specs/mcp-server-image/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,24 @@ The `service` stage SHALL stay the last stage of the `Dockerfile`.
#### Scenario: Service stage is last
- **WHEN** A test lists the stages of the `Dockerfile`.
- **THEN** The last stage is `service` and `mcp-server` comes before it.

### Requirement: The release publishes the MCP server image
The `release.yml` workflow SHALL build, smoke-test, scan, push by digest, attest and tag the `mcp-server` image, in that order, only in the run that creates a release. It SHALL tag the image with the release tag and `latest`.

#### Scenario: Publish job order
- **WHEN** A test reads job `mcp-server-image` of `release.yml`.
- **THEN** The job needs `release-please`, runs only when `release_created` is `true`, builds target `mcp-server`, pushes with `push-by-digest=true`, attests `ghcr.io/${{ github.repository }}/mcp-server`, and its steps keep the order of the `runner-image` job.

### Requirement: The release gate equals the pull request gate
The smoke test and the vulnerability scan of the release job SHALL equal those of job `mcp-server-image` in `ci.yml`.

#### Scenario: Same smoke test and scan
- **WHEN** A test compares the two jobs.
- **THEN** The smoke test scripts are equal and the inputs of the Trivy steps are equal.

### Requirement: Each image of this repository in k8s has a publish job
Each value of the keys `image` and `imageName` under `k8s/` that starts with `ghcr.io/dan-petty/devops-cli/` SHALL name an image that a job of `release.yml` attests.

#### Scenario: Manifest names an unpublished image
- **WHEN** A manifest under `k8s/` names `ghcr.io/dan-petty/devops-cli/<name>` and no job of `release.yml` attests `<name>`.
- **THEN** The test fails and names the image and the file.
Loading