From 1e0c16f0dc67246ccb8005965c289aba4114bd56 Mon Sep 17 00:00:00 2001 From: Brian DeHamer Date: Fri, 6 Dec 2024 14:27:02 -0800 Subject: [PATCH] return artifact digest on upload Signed-off-by: Brian DeHamer --- packages/artifact/__tests__/upload-artifact.test.ts | 4 +++- packages/artifact/src/internal/shared/interfaces.ts | 5 +++++ packages/artifact/src/internal/upload/upload-artifact.ts | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/artifact/__tests__/upload-artifact.test.ts b/packages/artifact/__tests__/upload-artifact.test.ts index 7c7d8e2e..64cc4fb1 100644 --- a/packages/artifact/__tests__/upload-artifact.test.ts +++ b/packages/artifact/__tests__/upload-artifact.test.ts @@ -281,7 +281,7 @@ describe('upload-artifact', () => { } ) - const {id, size} = await uploadArtifact( + const {id, size, digest} = await uploadArtifact( fixtures.inputs.artifactName, fixtures.files.map(file => path.join(fixtures.uploadDirectory, file.name) @@ -291,6 +291,8 @@ describe('upload-artifact', () => { expect(id).toBe(1) expect(size).toBe(loadedBytes) + expect(digest).toBeDefined() + expect(digest).toHaveLength(64) const extractedDirectory = path.join( fixtures.uploadDirectory, diff --git a/packages/artifact/src/internal/shared/interfaces.ts b/packages/artifact/src/internal/shared/interfaces.ts index eb55ae8b..4255d020 100644 --- a/packages/artifact/src/internal/shared/interfaces.ts +++ b/packages/artifact/src/internal/shared/interfaces.ts @@ -12,6 +12,11 @@ export interface UploadArtifactResponse { * This ID can be used as input to other APIs to download, delete or get more information about an artifact: https://docs.github.com/en/rest/actions/artifacts */ id?: number + + /** + * The SHA256 digest of the artifact that was created. Not provided if no artifact was uploaded + */ + digest?: string } /** diff --git a/packages/artifact/src/internal/upload/upload-artifact.ts b/packages/artifact/src/internal/upload/upload-artifact.ts index e880102f..81be322c 100644 --- a/packages/artifact/src/internal/upload/upload-artifact.ts +++ b/packages/artifact/src/internal/upload/upload-artifact.ts @@ -110,6 +110,7 @@ export async function uploadArtifact( return { size: uploadResult.uploadSize, + digest: uploadResult.sha256Hash, id: Number(artifactId) } }