From 27e3373f04f104374f75b8ef4b1e8057f6eea20c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Mon, 23 Nov 2026 09:05:22 +0100 Subject: [PATCH] fix(ci): keep the release chain running past a skipped approval The off-schedule approval job is skipped on every scheduled tag. GitHub skips any job whose dependency chain contains a skipped job unless its own condition replaces the implicit success(), so on the first real tag every job after the builds was skipped: no multi-arch manifest, no signature, no provenance, no release assets, and the run still reported success. Every job after build now states its condition on the results it depends on. A guard walks every workflow and fails when a job below a skippable job leaves the implicit success() in place. --- .github/workflows/docker-publish.yml | 25 ++++++++- scripts/__tests__/release-workflows.test.ts | 60 ++++++++++++++++++++- 2 files changed, 82 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 738e392f4..3b7e2ca3b 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -362,7 +362,14 @@ jobs: merge: name: Merge multi-arch manifest runs-on: ubuntu-24.04 - if: github.event_name != 'pull_request' + # A skipped job anywhere upstream (the off-schedule approval on every + # scheduled tag) makes GitHub skip every job below it whose condition + # leaves the implicit success() in place. Each job after `build` therefore + # states its own condition on the results it depends on. + if: >- + !cancelled() && + github.event_name != 'pull_request' && + needs.build.result == 'success' needs: [build] timeout-minutes: 10 outputs: @@ -483,6 +490,7 @@ jobs: verify-published-image: name: Verify exact published image needs: merge + if: "!cancelled() && needs.merge.result == 'success'" permissions: contents: read packages: read @@ -511,7 +519,11 @@ jobs: release-manifest: name: Sign release manifest needs: [merge, verify-published-image] - if: startsWith(github.ref, 'refs/tags/v') + if: >- + !cancelled() && + startsWith(github.ref, 'refs/tags/v') && + needs.merge.result == 'success' && + needs.verify-published-image.result == 'success' runs-on: ubuntu-24.04 timeout-minutes: 10 permissions: @@ -602,6 +614,7 @@ jobs: release-provenance: name: SLSA provenance for the release manifest needs: [release-manifest] + if: "!cancelled() && needs.release-manifest.result == 'success'" permissions: actions: read id-token: write @@ -619,6 +632,10 @@ jobs: release-assets: name: Attach signed manifest to the GitHub release needs: [release-manifest, release-provenance] + if: >- + !cancelled() && + needs.release-manifest.result == 'success' && + needs.release-provenance.result == 'success' runs-on: ubuntu-24.04 timeout-minutes: 10 permissions: @@ -667,6 +684,10 @@ jobs: promote: name: Promote verified image to Coolify needs: [merge, verify-published-image] + if: >- + !cancelled() && + needs.merge.result == 'success' && + needs.verify-published-image.result == 'success' runs-on: ubuntu-24.04 timeout-minutes: 5 permissions: diff --git a/scripts/__tests__/release-workflows.test.ts b/scripts/__tests__/release-workflows.test.ts index 94bb48326..75112f8ff 100644 --- a/scripts/__tests__/release-workflows.test.ts +++ b/scripts/__tests__/release-workflows.test.ts @@ -726,7 +726,8 @@ describe("signed release assets", () => { const workflow = loadWorkflow("docker-publish.yml"); const manifest = workflow.jobs["release-manifest"]; - expect(manifest?.if).toBe("startsWith(github.ref, 'refs/tags/v')"); + const manifestIf = (manifest?.if ?? "").replace(/\s+/g, " "); + expect(manifestIf).toContain("startsWith(github.ref, 'refs/tags/v')"); expect(manifest?.needs).toEqual(["merge", "verify-published-image"]); expect(workflow.jobs["release-provenance"]?.needs).toEqual([ "release-manifest", @@ -855,3 +856,60 @@ describe("signed release assets", () => { expect(script).not.toMatch(/release edit|--draft=false|--latest/); }); }); + +describe("skipped jobs do not silently end a chain", () => { + // GitHub skips a job when ANY job in its dependency chain was skipped, + // unless the job's own condition replaces the implicit success(). The + // off-schedule approval is skipped on every scheduled tag, so before this + // guard every job after `build` was skipped on the first real release: + // no manifest, no signature, no provenance, no release assets, all green. + const files = readdirSync( + join( + dirname(new URL(import.meta.url).pathname), + "../..", + ".github/workflows", + ), + ).filter((f) => /\.ya?ml$/.test(f)); + + it("finds the workflows and the conditional jobs it reasons about", () => { + expect(files).toContain("docker-publish.yml"); + const jobs = loadWorkflow("docker-publish.yml").jobs; + expect(jobs["off-schedule-approval"]?.if).toBeTruthy(); + }); + + for (const file of files) { + it(`${file}: every job below a skippable job states its own condition`, () => { + const jobs = (loadWorkflow(file).jobs ?? {}) as Record< + string, + { needs?: string | string[]; if?: string; steps?: unknown } + >; + const needsOf = (id: string): string[] => { + const n = jobs[id]?.needs; + return n === undefined ? [] : Array.isArray(n) ? n : [n]; + }; + const skippable = new Map(); + const canSkip = (id: string): boolean => { + const known = skippable.get(id); + if (known !== undefined) return known; + const value = + Boolean(jobs[id]?.if) || needsOf(id).some((need) => canSkip(need)); + skippable.set(id, value); + return value; + }; + const offenders: string[] = []; + for (const id of Object.keys(jobs)) { + const upstream = needsOf(id); + if (!upstream.some((need) => canSkip(need))) continue; + const condition = (jobs[id]?.if ?? "").replace(/\s+/g, " "); + // The results may be checked in the condition or, for an aggregate + // job that runs under always(), in its own steps. + const body = JSON.stringify(jobs[id]); + const explicit = + /!cancelled\(\)|always\(\)/.test(condition) && + upstream.every((need) => body.includes(`needs.${need}.result`)); + if (!explicit) offenders.push(id); + } + expect(offenders).toEqual([]); + }); + } +});