Upload with artifacts-legacy when running GHES, else with artifacts

`@actions/artifacts@v1` is still not yet supported on GHES and we need to maintain backwards compatibility here. If we detect that a user is running on GHES, we fall back on the original `v1` import.
This commit is contained in:
Angela P Wen
2024-09-04 14:07:49 -07:00
parent cdcb85f97a
commit d5ac485319
12 changed files with 133 additions and 38 deletions
+19 -6
View File
@@ -29,6 +29,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
* other `post:` hooks.
*/
const artifact = __importStar(require("@actions/artifact"));
const artifactLegacy = __importStar(require("@actions/artifact-legacy"));
const core = __importStar(require("@actions/core"));
const actionsUtil = __importStar(require("./actions-util"));
const configUtils = __importStar(require("./config-utils"));
@@ -47,13 +48,25 @@ async function runWrapper() {
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;
}
try {
await artifact
.create()
.uploadArtifact("proxy-log-file", [logFilePath], actionsUtil.getTemporaryDirectory(), {
continueOnError: true,
retentionDays: 7,
});
if (config.gitHubVersion.type === util_1.GitHubVariant.GHES) {
await artifactLegacy
.create()
.uploadArtifact("proxy-log-file", [logFilePath], actionsUtil.getTemporaryDirectory(), {
continueOnError: true,
retentionDays: 7,
});
}
else {
const artifactClient = new artifact.DefaultArtifactClient();
await artifactClient.uploadArtifact("proxy-log-file", [logFilePath], actionsUtil.getTemporaryDirectory(), {
retentionDays: 7,
});
}
}
catch (e) {
// A failure to upload debug artifacts should not fail the entire action.