diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 06ce1d0b6..6e08611c6 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -134,6 +134,10 @@ jobs: RUNTIME_VERSION="${RUNTIME_TAG#archie/}" [ -n "$GATEWAY_VERSION" ] || GATEWAY_VERSION=dev [ -n "$RUNTIME_VERSION" ] || RUNTIME_VERSION=dev + # Keep the raw tag presence separate from the version fallback: + # gateway-only releases must not rebuild the runtime image as dev. + echo "gateway_tag=$GATEWAY_TAG" >> "$GITHUB_OUTPUT" + echo "runtime_tag=$RUNTIME_TAG" >> "$GITHUB_OUTPUT" echo "gateway=$GATEWAY_VERSION" >> "$GITHUB_OUTPUT" echo "runtime=$RUNTIME_VERSION" >> "$GITHUB_OUTPUT" @@ -151,6 +155,7 @@ jobs: cache-to: type=gha,mode=max,scope=archied - name: Build and push archie-agent + if: steps.versions.outputs.runtime_tag != '' uses: docker/build-push-action@v6 with: context: . diff --git a/deploy_workflow_test.go b/deploy_workflow_test.go new file mode 100644 index 000000000..db92c3f8e --- /dev/null +++ b/deploy_workflow_test.go @@ -0,0 +1,42 @@ +package configtemplate + +import ( + "strings" + "testing" +) + +func TestDeployWorkflowOnlyPublishesRuntimeImageForRuntimeTag(t *testing.T) { + source := readDeploymentFile(t, ".github/workflows/deploy.yml") + + // The fallback remains necessary because Dockerfile.archied accepts a + // runtime version, but it must not be used as the image-publish selector. + for _, required := range []string{ + `RUNTIME_TAG="$(git tag --points-at HEAD --list 'archie/v*' | sort -V | tail -1)"`, + `echo "runtime_tag=$RUNTIME_TAG" >> "$GITHUB_OUTPUT"`, + "if: steps.versions.outputs.runtime_tag != ''", + } { + if !strings.Contains(source, required) { + t.Errorf("deploy workflow is missing runtime-image guard %q", required) + } + } + + // The gateway build remains unconditional, while the runtime build is + // guarded. This verifies both sides of the gateway-only/dual-tag contract. + agentMarker := " - name: Build and push archie-agent\n" + agentStart := strings.Index(source, agentMarker) + if agentStart < 0 { + t.Fatal("deploy workflow has no archie-agent build step") + } + if !strings.Contains(source[agentStart:], agentMarker+" if: steps.versions.outputs.runtime_tag != ''\n") { + t.Fatal("archie-agent build step is not conditionally enabled") + } + + gatewayMarker := " - name: Build and push archied\n" + gatewayStart := strings.Index(source, gatewayMarker) + if gatewayStart < 0 { + t.Fatal("deploy workflow has no archied build step") + } + if strings.Contains(source[gatewayStart:agentStart], "\n if:") { + t.Fatal("archied build step is unexpectedly conditional") + } +}