mirror of https://github.com/actions/toolkit
wrap promises in chain
parent
f33a3f4748
commit
180b75bf01
|
@ -68,45 +68,81 @@ export async function uploadArtifact(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const zipUploadStream = await createZipUploadStream(
|
return createZipUploadStream(zipSpecification, options?.compressionLevel)
|
||||||
zipSpecification,
|
.then(async zipUploadStream => {
|
||||||
options?.compressionLevel
|
return uploadZipToBlobStorage(
|
||||||
)
|
createArtifactResp.signedUploadUrl,
|
||||||
|
zipUploadStream
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.then(async uploadResult => {
|
||||||
|
const finalizeArtifactReq: FinalizeArtifactRequest = {
|
||||||
|
workflowRunBackendId: backendIds.workflowRunBackendId,
|
||||||
|
workflowJobRunBackendId: backendIds.workflowJobRunBackendId,
|
||||||
|
name,
|
||||||
|
size: uploadResult.uploadSize ? uploadResult.uploadSize.toString() : '0'
|
||||||
|
}
|
||||||
|
if (uploadResult.sha256Hash) {
|
||||||
|
finalizeArtifactReq.hash = StringValue.create({
|
||||||
|
value: `sha256:${uploadResult.sha256Hash}`
|
||||||
|
})
|
||||||
|
}
|
||||||
|
core.info(`Finalizing artifact upload`)
|
||||||
|
const finalizeArtifactResp =
|
||||||
|
await artifactClient.FinalizeArtifact(finalizeArtifactReq)
|
||||||
|
|
||||||
// Upload zip to blob storage
|
return {finalizeArtifactResp, uploadResult}
|
||||||
const uploadResult = await uploadZipToBlobStorage(
|
})
|
||||||
createArtifactResp.signedUploadUrl,
|
.then(({finalizeArtifactResp, uploadResult}) => {
|
||||||
zipUploadStream
|
if (!finalizeArtifactResp.ok) {
|
||||||
)
|
throw new InvalidResponseError(
|
||||||
|
'FinalizeArtifact: response from backend was not ok'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
const artifactId = BigInt(finalizeArtifactResp.artifactId)
|
||||||
|
core.info(
|
||||||
|
`Artifact ${name}.zip successfully finalized. Artifact ID ${artifactId}`
|
||||||
|
)
|
||||||
|
return {
|
||||||
|
size: uploadResult.uploadSize,
|
||||||
|
id: Number(artifactId)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
// // Upload zip to blob storage
|
||||||
|
// const uploadResult = await uploadZipToBlobStorage(
|
||||||
|
// createArtifactResp.signedUploadUrl,
|
||||||
|
// zipUploadStream
|
||||||
|
// )
|
||||||
|
|
||||||
// finalize the artifact
|
// finalize the artifact
|
||||||
const finalizeArtifactReq: FinalizeArtifactRequest = {
|
// const finalizeArtifactReq: FinalizeArtifactRequest = {
|
||||||
workflowRunBackendId: backendIds.workflowRunBackendId,
|
// workflowRunBackendId: backendIds.workflowRunBackendId,
|
||||||
workflowJobRunBackendId: backendIds.workflowJobRunBackendId,
|
// workflowJobRunBackendId: backendIds.workflowJobRunBackendId,
|
||||||
name,
|
// name,
|
||||||
size: uploadResult.uploadSize ? uploadResult.uploadSize.toString() : '0'
|
// size: uploadResult.uploadSize ? uploadResult.uploadSize.toString() : '0'
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (uploadResult.sha256Hash) {
|
// if (uploadResult.sha256Hash) {
|
||||||
finalizeArtifactReq.hash = StringValue.create({
|
// finalizeArtifactReq.hash = StringValue.create({
|
||||||
value: `sha256:${uploadResult.sha256Hash}`
|
// value: `sha256:${uploadResult.sha256Hash}`
|
||||||
})
|
// })
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
// core.info(`Finalizing artifact upload`)
|
||||||
|
|
||||||
core.info(`Finalizing artifact upload`)
|
// const finalizeArtifactResp =
|
||||||
|
// await artifactClient.FinalizeArtifact(finalizeArtifactReq)
|
||||||
|
// if (!finalizeArtifactResp.ok) {
|
||||||
|
// throw new InvalidResponseError(
|
||||||
|
// 'FinalizeArtifact: response from backend was not ok'
|
||||||
|
// )
|
||||||
|
// }
|
||||||
|
|
||||||
const finalizeArtifactResp =
|
// const artifactId = BigInt(finalizeArtifactResp.artifactId)
|
||||||
await artifactClient.FinalizeArtifact(finalizeArtifactReq)
|
// core.info(
|
||||||
if (!finalizeArtifactResp.ok) {
|
// `Artifact ${name}.zip successfully finalized. Artifact ID ${artifactId}`
|
||||||
throw new InvalidResponseError(
|
// )
|
||||||
'FinalizeArtifact: response from backend was not ok'
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
const artifactId = BigInt(finalizeArtifactResp.artifactId)
|
|
||||||
core.info(
|
|
||||||
`Artifact ${name}.zip successfully finalized. Artifact ID ${artifactId}`
|
|
||||||
)
|
|
||||||
// if (core.isDebug()) {
|
// if (core.isDebug()) {
|
||||||
// setTimeout(function () {
|
// setTimeout(function () {
|
||||||
// core.debug('Processes keeping upload stream running:')
|
// core.debug('Processes keeping upload stream running:')
|
||||||
|
@ -115,8 +151,5 @@ export async function uploadArtifact(
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
|
|
||||||
return {
|
// )
|
||||||
size: uploadResult.uploadSize,
|
|
||||||
id: Number(artifactId)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue