diff --git a/dist/main/index.js b/dist/main/index.js index c62b7cb..e99b75f 100644 --- a/dist/main/index.js +++ b/dist/main/index.js @@ -4385,20 +4385,23 @@ Please add a step this step to your workflow's job definition: function prepareBuildx() { return __awaiter(this, void 0, void 0, function* () { try { - yield core.group(`Ensure Namespace Builder proxy is already configured`, () => __awaiter(this, void 0, void 0, function* () { + const exists = yield core.group(`Ensure Namespace Builder proxy is already configured`, () => __awaiter(this, void 0, void 0, function* () { const builderExists = yield remoteNscBuilderExists(); if (builderExists) { core.info(`GitHub runner is already configured to use Namespace Cloud build cluster.`); - return; + return true; } core.info(`Namespace Builder is not yet configured.`); + return false; })); - const sock = tmpFile("buildkit-proxy.sock"); - yield core.group(`Proxy Buildkit from Namespace Cloud`, () => __awaiter(this, void 0, void 0, function* () { - yield ensureNscloudToken(); - yield exec.exec(`nsc cluster proxy --kind=buildkit --cluster=build-cluster --sock_path=${sock} --background=${ProxyPidFile}`); - yield exec.exec(`docker buildx create --name ${nscRemoteBuilderName} --driver remote unix://${sock} --use`); - })); + if (!exists) { + const sock = tmpFile("buildkit-proxy.sock"); + yield core.group(`Proxy Buildkit from Namespace Cloud`, () => __awaiter(this, void 0, void 0, function* () { + yield ensureNscloudToken(); + yield exec.exec(`nsc cluster proxy --kind=buildkit --cluster=build-cluster --sock_path=${sock} --background=${ProxyPidFile}`); + yield exec.exec(`docker buildx create --name ${nscRemoteBuilderName} --driver remote unix://${sock} --use`); + })); + } yield core.group(`Builder`, () => __awaiter(this, void 0, void 0, function* () { core.info(nscRemoteBuilderName); })); diff --git a/main.ts b/main.ts index 40620ec..e0d3f98 100644 --- a/main.ts +++ b/main.ts @@ -21,28 +21,31 @@ Please add a step this step to your workflow's job definition: async function prepareBuildx(): Promise { try { - await core.group(`Ensure Namespace Builder proxy is already configured`, async () => { + const exists = await core.group(`Ensure Namespace Builder proxy is already configured`, async (): Promise => { const builderExists = await remoteNscBuilderExists(); if (builderExists) { core.info(`GitHub runner is already configured to use Namespace Cloud build cluster.`); - return; + return true; } core.info(`Namespace Builder is not yet configured.`); + return false; }); - - const sock = tmpFile("buildkit-proxy.sock"); - - await core.group(`Proxy Buildkit from Namespace Cloud`, async () => { - await ensureNscloudToken(); - - await exec.exec( - `nsc cluster proxy --kind=buildkit --cluster=build-cluster --sock_path=${sock} --background=${ProxyPidFile}` - ); - - await exec.exec( - `docker buildx create --name ${nscRemoteBuilderName} --driver remote unix://${sock} --use` - ); - }); + + if (!exists) { + const sock = tmpFile("buildkit-proxy.sock"); + + await core.group(`Proxy Buildkit from Namespace Cloud`, async () => { + await ensureNscloudToken(); + + await exec.exec( + `nsc cluster proxy --kind=buildkit --cluster=build-cluster --sock_path=${sock} --background=${ProxyPidFile}` + ); + + await exec.exec( + `docker buildx create --name ${nscRemoteBuilderName} --driver remote unix://${sock} --use` + ); + }); + } await core.group(`Builder`, async () => { core.info(nscRemoteBuilderName);