diff --git a/common.ts b/common.ts index d295782..feacd87 100644 --- a/common.ts +++ b/common.ts @@ -1 +1,3 @@ export const nscRemoteBuilderName = "nsc-remote"; +export const nscDebugFilePath = "/home/runner/nsc/buildkit_proxy.log"; +export const nscVmIdKey = 'NSC_VM_ID'; diff --git a/dist/main/index.js b/dist/main/index.js index 65e3a22..fac4458 100644 --- a/dist/main/index.js +++ b/dist/main/index.js @@ -4319,6 +4319,8 @@ var exec = __nccwpck_require__(514); var external_fs_ = __nccwpck_require__(147); ;// CONCATENATED MODULE: ./common.ts const nscRemoteBuilderName = "nsc-remote"; +const nscDebugFilePath = "/home/runner/nsc/buildkit_proxy.log"; +const nscVmIdKey = 'NSC_VM_ID'; ;// CONCATENATED MODULE: ./main.ts var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) { @@ -4363,7 +4365,15 @@ function prepareBuildx() { if (!exists) { yield core.group(`Proxy Buildkit from Namespace Cloud`, () => __awaiter(this, void 0, void 0, function* () { yield ensureNscloudToken(); - yield exec.exec(`nsc docker buildx setup --name=${nscRemoteBuilderName} --background --use`); + const nscRunner = yield isNscRunner(); + if (nscRunner) { + core.debug(`Environment is Namespace Runner`); + yield exec.exec(`nsc docker buildx setup --name=${nscRemoteBuilderName} --background --use --debug_to_file=${nscDebugFilePath}`); + } + else { + core.debug(`Environment is not Namespace Runner`); + yield exec.exec(`nsc docker buildx setup --name=${nscRemoteBuilderName} --background --use`); + } })); } yield core.group(`Builder`, () => __awaiter(this, void 0, void 0, function* () { @@ -4396,6 +4406,12 @@ function remoteNscBuilderExists() { return !(stdout.includes(builderNotFoundStr) || stderr.includes(builderNotFoundStr)); }); } +function isNscRunner() { + return __awaiter(this, void 0, void 0, function* () { + const vmID = process.env[`${nscVmIdKey}`] || ""; + return vmID !== ""; + }); +} run(); })(); diff --git a/main.ts b/main.ts index 6b57ddc..15c6aaa 100644 --- a/main.ts +++ b/main.ts @@ -1,7 +1,7 @@ import * as core from "@actions/core"; import * as exec from "@actions/exec"; import * as fs from "fs"; -import { nscRemoteBuilderName } from "./common"; +import { nscRemoteBuilderName, nscDebugFilePath, nscVmIdKey } from "./common"; async function run(): Promise { var commandExists = require("command-exists"); @@ -38,9 +38,18 @@ async function prepareBuildx(): Promise { await core.group(`Proxy Buildkit from Namespace Cloud`, async () => { await ensureNscloudToken(); - await exec.exec( - `nsc docker buildx setup --name=${nscRemoteBuilderName} --background --use` - ); + const nscRunner = await isNscRunner(); + if (nscRunner) { + core.debug(`Environment is Namespace Runner`); + await exec.exec( + `nsc docker buildx setup --name=${nscRemoteBuilderName} --background --use --debug_to_file=${nscDebugFilePath}` + ); + } else { + core.debug(`Environment is not Namespace Runner`); + await exec.exec( + `nsc docker buildx setup --name=${nscRemoteBuilderName} --background --use` + ); + } }); } @@ -79,4 +88,9 @@ async function remoteNscBuilderExists(): Promise { ); } +async function isNscRunner(): Promise { + const vmID: string = process.env[`${nscVmIdKey}`] || ""; + return vmID !== ""; +} + run();