diff --git a/lib/start-proxy-action-post.js b/lib/start-proxy-action-post.js index d0590d4bbf..6fbd47eb27 100644 --- a/lib/start-proxy-action-post.js +++ b/lib/start-proxy-action-post.js @@ -46,39 +46,35 @@ const debug_artifacts_1 = require("./debug-artifacts"); const logging_1 = require("./logging"); const util_1 = require("./util"); async function runWrapper() { + const logger = (0, logging_1.getActionsLogger)(); try { // Restore inputs from `start-proxy` Action. actionsUtil.restoreInputs(); + // Kill the running proxy const pid = core.getState("proxy-process-pid"); if (pid) { process.kill(Number(pid)); } - } - catch (error) { - core.setFailed(`start-proxy post-action step failed: ${(0, util_1.getErrorMessage)(error)}`); - } - const config = await configUtils.getConfig(actionsUtil.getTemporaryDirectory(), core); - if ((config && config.debugMode) || core.isDebug()) { - const logFilePath = core.getState("proxy-log-file"); - core.info("Debug mode is on. Uploading proxy log as Actions debugging artifact..."); - if (config?.gitHubVersion.type === undefined) { - core.warning(`Did not upload debug artifacts because cannot determine the GitHub variant running.`); - return; - } - const logger = (0, logging_1.getActionsLogger)(); - const gitHubVersion = await (0, api_client_1.getGitHubVersion)(); - (0, util_1.checkGitHubVersionInRange)(gitHubVersion, logger); - try { + const config = await configUtils.getConfig(actionsUtil.getTemporaryDirectory(), logger); + if ((config && config.debugMode) || core.isDebug()) { + const logFilePath = core.getState("proxy-log-file"); + logger.info("Debug mode is on. Uploading proxy log as Actions debugging artifact..."); + if (config?.gitHubVersion.type === undefined) { + logger.warning(`Did not upload debug artifacts because cannot determine the GitHub variant running.`); + return; + } + const gitHubVersion = await (0, api_client_1.getGitHubVersion)(); + (0, util_1.checkGitHubVersionInRange)(gitHubVersion, logger); const artifactUploader = await (0, debug_artifacts_1.getArtifactUploaderClient)(logger, gitHubVersion.type); await artifactUploader.uploadArtifact("proxy-log-file", [logFilePath], actionsUtil.getTemporaryDirectory(), { // ensure we don't keep the debug artifacts around for too long since they can be large. retentionDays: 7, }); } - catch (e) { - // A failure to upload debug artifacts should not fail the entire action. - core.warning(`Failed to upload debug artifacts: ${e}`); - } + } + catch (error) { + // A failure in the post step should not fail the entire action. + logger.warning(`start-proxy post-action step failed: ${(0, util_1.getErrorMessage)(error)}`); } } void runWrapper(); diff --git a/lib/start-proxy-action-post.js.map b/lib/start-proxy-action-post.js.map index 5277ccaeed..04159830b9 100644 --- a/lib/start-proxy-action-post.js.map +++ b/lib/start-proxy-action-post.js.map @@ -1 +1 @@ -{"version":3,"file":"start-proxy-action-post.js","sourceRoot":"","sources":["../src/start-proxy-action-post.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;GAIG;AACH,oDAAsC;AAEtC,4DAA8C;AAC9C,6CAAgD;AAChD,4DAA8C;AAC9C,uDAA8D;AAC9D,uCAA6C;AAC7C,iCAAoE;AAEpE,KAAK,UAAU,UAAU;IACvB,IAAI,CAAC;QACH,4CAA4C;QAC5C,WAAW,CAAC,aAAa,EAAE,CAAC;QAC5B,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,mBAAmB,CAAC,CAAC;QAC/C,IAAI,GAAG,EAAE,CAAC;YACR,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,SAAS,CACZ,wCAAwC,IAAA,sBAAe,EAAC,KAAK,CAAC,EAAE,CACjE,CAAC;IACJ,CAAC;IACD,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,SAAS,CACxC,WAAW,CAAC,qBAAqB,EAAE,EACnC,IAAI,CACL,CAAC;IAEF,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,SAAS,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC;QACnD,MAAM,WAAW,GAAG,IAAI,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC;QACpD,IAAI,CAAC,IAAI,CACP,wEAAwE,CACzE,CAAC;QACF,IAAI,MAAM,EAAE,aAAa,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;YAC7C,IAAI,CAAC,OAAO,CACV,qFAAqF,CACtF,CAAC;YACF,OAAO;QACT,CAAC;QAED,MAAM,MAAM,GAAG,IAAA,0BAAgB,GAAE,CAAC;QAClC,MAAM,aAAa,GAAG,MAAM,IAAA,6BAAgB,GAAE,CAAC;QAC/C,IAAA,gCAAyB,EAAC,aAAa,EAAE,MAAM,CAAC,CAAC;QAEjD,IAAI,CAAC;YACH,MAAM,gBAAgB,GAAG,MAAM,IAAA,2CAAyB,EACtD,MAAM,EACN,aAAa,CAAC,IAAI,CACnB,CAAC;YAEF,MAAM,gBAAgB,CAAC,cAAc,CACnC,gBAAgB,EAChB,CAAC,WAAW,CAAC,EACb,WAAW,CAAC,qBAAqB,EAAE,EACnC;gBACE,wFAAwF;gBACxF,aAAa,EAAE,CAAC;aACjB,CACF,CAAC;QACJ,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,yEAAyE;YACzE,IAAI,CAAC,OAAO,CAAC,qCAAqC,CAAC,EAAE,CAAC,CAAC;QACzD,CAAC;IACH,CAAC;AACH,CAAC;AAED,KAAK,UAAU,EAAE,CAAC"} \ No newline at end of file +{"version":3,"file":"start-proxy-action-post.js","sourceRoot":"","sources":["../src/start-proxy-action-post.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;GAIG;AACH,oDAAsC;AAEtC,4DAA8C;AAC9C,6CAAgD;AAChD,4DAA8C;AAC9C,uDAA8D;AAC9D,uCAA6C;AAC7C,iCAAoE;AAEpE,KAAK,UAAU,UAAU;IACvB,MAAM,MAAM,GAAG,IAAA,0BAAgB,GAAE,CAAC;IAElC,IAAI,CAAC;QACH,4CAA4C;QAC5C,WAAW,CAAC,aAAa,EAAE,CAAC;QAE5B,yBAAyB;QACzB,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,mBAAmB,CAAC,CAAC;QAC/C,IAAI,GAAG,EAAE,CAAC;YACR,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;QAC5B,CAAC;QAED,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,SAAS,CACxC,WAAW,CAAC,qBAAqB,EAAE,EACnC,MAAM,CACP,CAAC;QAEF,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,SAAS,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC;YACnD,MAAM,WAAW,GAAG,IAAI,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC;YACpD,MAAM,CAAC,IAAI,CACT,wEAAwE,CACzE,CAAC;YACF,IAAI,MAAM,EAAE,aAAa,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;gBAC7C,MAAM,CAAC,OAAO,CACZ,qFAAqF,CACtF,CAAC;gBACF,OAAO;YACT,CAAC;YACD,MAAM,aAAa,GAAG,MAAM,IAAA,6BAAgB,GAAE,CAAC;YAC/C,IAAA,gCAAyB,EAAC,aAAa,EAAE,MAAM,CAAC,CAAC;YAEjD,MAAM,gBAAgB,GAAG,MAAM,IAAA,2CAAyB,EACtD,MAAM,EACN,aAAa,CAAC,IAAI,CACnB,CAAC;YAEF,MAAM,gBAAgB,CAAC,cAAc,CACnC,gBAAgB,EAChB,CAAC,WAAW,CAAC,EACb,WAAW,CAAC,qBAAqB,EAAE,EACnC;gBACE,wFAAwF;gBACxF,aAAa,EAAE,CAAC;aACjB,CACF,CAAC;QACJ,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,gEAAgE;QAChE,MAAM,CAAC,OAAO,CACZ,wCAAwC,IAAA,sBAAe,EAAC,KAAK,CAAC,EAAE,CACjE,CAAC;IACJ,CAAC;AACH,CAAC;AAED,KAAK,UAAU,EAAE,CAAC"} \ No newline at end of file diff --git a/src/start-proxy-action-post.ts b/src/start-proxy-action-post.ts index a9e38cf1c8..100b8a75ff 100644 --- a/src/start-proxy-action-post.ts +++ b/src/start-proxy-action-post.ts @@ -13,40 +13,37 @@ import { getActionsLogger } from "./logging"; import { checkGitHubVersionInRange, getErrorMessage } from "./util"; async function runWrapper() { + const logger = getActionsLogger(); + try { // Restore inputs from `start-proxy` Action. actionsUtil.restoreInputs(); + + // Kill the running proxy const pid = core.getState("proxy-process-pid"); if (pid) { process.kill(Number(pid)); } - } catch (error) { - core.setFailed( - `start-proxy post-action step failed: ${getErrorMessage(error)}`, - ); - } - const config = await configUtils.getConfig( - actionsUtil.getTemporaryDirectory(), - core, - ); - if ((config && config.debugMode) || core.isDebug()) { - const logFilePath = core.getState("proxy-log-file"); - core.info( - "Debug mode is on. Uploading proxy log as Actions debugging artifact...", + const config = await configUtils.getConfig( + actionsUtil.getTemporaryDirectory(), + logger, ); - if (config?.gitHubVersion.type === undefined) { - core.warning( - `Did not upload debug artifacts because cannot determine the GitHub variant running.`, - ); - return; - } - const logger = getActionsLogger(); - const gitHubVersion = await getGitHubVersion(); - checkGitHubVersionInRange(gitHubVersion, logger); + if ((config && config.debugMode) || core.isDebug()) { + const logFilePath = core.getState("proxy-log-file"); + logger.info( + "Debug mode is on. Uploading proxy log as Actions debugging artifact...", + ); + if (config?.gitHubVersion.type === undefined) { + logger.warning( + `Did not upload debug artifacts because cannot determine the GitHub variant running.`, + ); + return; + } + const gitHubVersion = await getGitHubVersion(); + checkGitHubVersionInRange(gitHubVersion, logger); - try { const artifactUploader = await getArtifactUploaderClient( logger, gitHubVersion.type, @@ -61,10 +58,12 @@ async function runWrapper() { retentionDays: 7, }, ); - } catch (e) { - // A failure to upload debug artifacts should not fail the entire action. - core.warning(`Failed to upload debug artifacts: ${e}`); } + } catch (error) { + // A failure in the post step should not fail the entire action. + logger.warning( + `start-proxy post-action step failed: ${getErrorMessage(error)}`, + ); } } diff --git a/start-proxy/action.yml b/start-proxy/action.yml index 5756bba479..dc783df80f 100644 --- a/start-proxy/action.yml +++ b/start-proxy/action.yml @@ -12,6 +12,10 @@ inputs: proxy_password: required: false description: The password of the proxy + token: + description: GitHub token to use for authenticating with this instance of GitHub, used to upload debug artifacts. + default: ${{ github.token }} + required: false outputs: proxy_host: description: The IP address of the proxy