From 8d0a4082a44403a7ed3f5d920b7b420a2cf72237 Mon Sep 17 00:00:00 2001 From: Abhi <43648792+abhipatel12@users.noreply.github.com> Date: Mon, 14 Jul 2025 00:19:58 -0400 Subject: Fix(ci): Correct container publishing pipeline and improve robustness (#4093) --- scripts/build_sandbox.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'scripts/build_sandbox.js') diff --git a/scripts/build_sandbox.js b/scripts/build_sandbox.js index 962f99d9..51d0556e 100644 --- a/scripts/build_sandbox.js +++ b/scripts/build_sandbox.js @@ -18,7 +18,7 @@ // limitations under the License. import { execSync } from 'child_process'; -import { chmodSync, readFileSync, rmSync } from 'fs'; +import { chmodSync, existsSync, readFileSync, rmSync, writeFileSync } from 'fs'; import { join } from 'path'; import yargs from 'yargs'; import { hideBin } from 'yargs/helpers'; @@ -134,6 +134,14 @@ function buildImage(imageName, dockerfile) { { stdio: buildStdout, shell: '/bin/bash' }, ); console.log(`built ${finalImageName}`); + if (existsSync('/workspace/final_image_uri.txt')) { + // The publish step only supports one image. If we build multiple, only the last one + // will be published. Throw an error to make this failure explicit. + throw new Error( + 'CI artifact file /workspace/final_image_uri.txt already exists. Refusing to overwrite.', + ); + } + writeFileSync('/workspace/final_image_uri.txt', finalImageName); } if (baseImage && baseDockerfile) { -- cgit v1.2.3