Skip to content

Commit

Permalink
Avoid failing the workflow on a proxy post step
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco Gario committed Dec 11, 2024
1 parent 4d64ab6 commit f327a84
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 47 deletions.
36 changes: 16 additions & 20 deletions lib/start-proxy-action-post.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/start-proxy-action-post.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 24 additions & 26 deletions src/start-proxy-action-post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,40 +13,38 @@ 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,
Expand All @@ -61,10 +59,10 @@ 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)}`);
}
}

Expand Down

0 comments on commit f327a84

Please sign in to comment.