Skip to content

Commit 26b076b

Browse files
committed
Refactor artifact client logic to reuse arguments
1 parent 3641023 commit 26b076b

File tree

6 files changed

+67
-73
lines changed

6 files changed

+67
-73
lines changed

lib/debug-artifacts.js

Lines changed: 11 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/debug-artifacts.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/start-proxy-action-post.js

Lines changed: 12 additions & 13 deletions
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

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/debug-artifacts.ts

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -160,29 +160,27 @@ export async function uploadDebugArtifacts(
160160

161161
try {
162162
// NB: Once `@actions/artifact@v2` is supported on GHES, we can remove usage of `artifact-legacy`.
163-
if (ghVariant === GitHubVariant.GHES) {
164-
await artifactLegacy.create().uploadArtifact(
165-
sanitizeArifactName(`${artifactName}${suffix}`),
166-
toUpload.map((file) => path.normalize(file)),
167-
path.normalize(rootDir),
168-
{
169-
continueOnError: true,
170-
// ensure we don't keep the debug artifacts around for too long since they can be large.
171-
retentionDays: 7,
172-
},
173-
);
174-
} else {
175-
const artifactClient = new artifact.DefaultArtifactClient();
176-
await artifactClient.uploadArtifact(
177-
sanitizeArifactName(`${artifactName}${suffix}`),
178-
toUpload.map((file) => path.normalize(file)),
179-
path.normalize(rootDir),
180-
{
181-
// ensure we don't keep the debug artifacts around for too long since they can be large.
182-
retentionDays: 7,
183-
},
184-
);
185-
}
163+
const artifactUploader =
164+
ghVariant === GitHubVariant.GHES
165+
? artifactLegacy.create()
166+
: new artifact.DefaultArtifactClient();
167+
168+
const artifactUploaderArgs: [
169+
string, // artifact name
170+
string[], // file paths to upload
171+
string, // root directory
172+
artifact.UploadArtifactOptions,
173+
] = [
174+
sanitizeArifactName(`${artifactName}${suffix}`),
175+
toUpload.map((file) => path.normalize(file)),
176+
path.normalize(rootDir),
177+
{
178+
// ensure we don't keep the debug artifacts around for too long since they can be large.
179+
retentionDays: 7,
180+
},
181+
];
182+
183+
await artifactUploader.uploadArtifact(...artifactUploaderArgs);
186184
} catch (e) {
187185
// A failure to upload debug artifacts should not fail the entire action.
188186
core.warning(`Failed to upload debug artifacts: ${e}`);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy