Skip to content

Commit 78d0136

Browse files
authored
Merge pull request #2643 from github/marcogario/robustify_start_proxy_post
Start Proxy: Make the post step more robust to errors
2 parents c4bbe15 + 47dd68e commit 78d0136

File tree

4 files changed

+46
-47
lines changed

4 files changed

+46
-47
lines changed

lib/start-proxy-action-post.js

+16-20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/start-proxy-action-post.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/start-proxy-action-post.ts

+25-26
Original file line numberDiff line numberDiff line change
@@ -13,40 +13,37 @@ import { getActionsLogger } from "./logging";
1313
import { checkGitHubVersionInRange, getErrorMessage } from "./util";
1414

1515
async function runWrapper() {
16+
const logger = getActionsLogger();
17+
1618
try {
1719
// Restore inputs from `start-proxy` Action.
1820
actionsUtil.restoreInputs();
21+
22+
// Kill the running proxy
1923
const pid = core.getState("proxy-process-pid");
2024
if (pid) {
2125
process.kill(Number(pid));
2226
}
23-
} catch (error) {
24-
core.setFailed(
25-
`start-proxy post-action step failed: ${getErrorMessage(error)}`,
26-
);
27-
}
28-
const config = await configUtils.getConfig(
29-
actionsUtil.getTemporaryDirectory(),
30-
core,
31-
);
3227

33-
if ((config && config.debugMode) || core.isDebug()) {
34-
const logFilePath = core.getState("proxy-log-file");
35-
core.info(
36-
"Debug mode is on. Uploading proxy log as Actions debugging artifact...",
28+
const config = await configUtils.getConfig(
29+
actionsUtil.getTemporaryDirectory(),
30+
logger,
3731
);
38-
if (config?.gitHubVersion.type === undefined) {
39-
core.warning(
40-
`Did not upload debug artifacts because cannot determine the GitHub variant running.`,
41-
);
42-
return;
43-
}
4432

45-
const logger = getActionsLogger();
46-
const gitHubVersion = await getGitHubVersion();
47-
checkGitHubVersionInRange(gitHubVersion, logger);
33+
if ((config && config.debugMode) || core.isDebug()) {
34+
const logFilePath = core.getState("proxy-log-file");
35+
logger.info(
36+
"Debug mode is on. Uploading proxy log as Actions debugging artifact...",
37+
);
38+
if (config?.gitHubVersion.type === undefined) {
39+
logger.warning(
40+
`Did not upload debug artifacts because cannot determine the GitHub variant running.`,
41+
);
42+
return;
43+
}
44+
const gitHubVersion = await getGitHubVersion();
45+
checkGitHubVersionInRange(gitHubVersion, logger);
4846

49-
try {
5047
const artifactUploader = await getArtifactUploaderClient(
5148
logger,
5249
gitHubVersion.type,
@@ -61,10 +58,12 @@ async function runWrapper() {
6158
retentionDays: 7,
6259
},
6360
);
64-
} catch (e) {
65-
// A failure to upload debug artifacts should not fail the entire action.
66-
core.warning(`Failed to upload debug artifacts: ${e}`);
6761
}
62+
} catch (error) {
63+
// A failure in the post step should not fail the entire action.
64+
logger.warning(
65+
`start-proxy post-action step failed: ${getErrorMessage(error)}`,
66+
);
6867
}
6968
}
7069

start-proxy/action.yml

+4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ inputs:
1212
proxy_password:
1313
required: false
1414
description: The password of the proxy
15+
token:
16+
description: GitHub token to use for authenticating with this instance of GitHub, used to upload debug artifacts.
17+
default: ${{ github.token }}
18+
required: false
1519
outputs:
1620
proxy_host:
1721
description: The IP address of the proxy

0 commit comments

Comments
 (0)