mirror of https://github.com/actions/toolkit
re-adding old async/await pattern
parent
5288db3953
commit
0f23ae1184
|
@ -67,94 +67,43 @@ export async function uploadArtifact(
|
||||||
'CreateArtifact: response from backend was not ok'
|
'CreateArtifact: response from backend was not ok'
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
const zipUploadStream = await createZipUploadStream(
|
||||||
return createZipUploadStream(zipSpecification, options?.compressionLevel)
|
zipSpecification,
|
||||||
.then(async zipUploadStream => {
|
options?.compressionLevel
|
||||||
core.info(`starting upload to blob here`)
|
)
|
||||||
core.info(`zipuploadstream looks like this: ${zipUploadStream}`)
|
// Upload zip to blob storage
|
||||||
return uploadZipToBlobStorage(
|
const uploadResult = await uploadZipToBlobStorage(
|
||||||
createArtifactResp.signedUploadUrl,
|
createArtifactResp.signedUploadUrl,
|
||||||
zipUploadStream
|
zipUploadStream
|
||||||
).catch(err => {
|
)
|
||||||
core.error(`Error uploading artifact: ${err}`)
|
|
||||||
throw err
|
|
||||||
})
|
|
||||||
})
|
|
||||||
.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)
|
|
||||||
|
|
||||||
return {finalizeArtifactResp, uploadResult}
|
|
||||||
})
|
|
||||||
.then(({finalizeArtifactResp, uploadResult}) => {
|
|
||||||
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) {
|
||||||
|
finalizeArtifactReq.hash = StringValue.create({
|
||||||
|
value: `sha256:${uploadResult.sha256Hash}`
|
||||||
|
})
|
||||||
|
}
|
||||||
|
core.info(`Finalizing artifact upload`)
|
||||||
|
const finalizeArtifactResp =
|
||||||
|
await artifactClient.FinalizeArtifact(finalizeArtifactReq)
|
||||||
|
if (!finalizeArtifactResp.ok) {
|
||||||
|
throw new InvalidResponseError(
|
||||||
|
'FinalizeArtifact: response from backend was not ok'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
// if (uploadResult.sha256Hash) {
|
const artifactId = BigInt(finalizeArtifactResp.artifactId)
|
||||||
// finalizeArtifactReq.hash = StringValue.create({
|
core.info(
|
||||||
// value: `sha256:${uploadResult.sha256Hash}`
|
`Artifact ${name}.zip successfully finalized. Artifact ID ${artifactId}`
|
||||||
// })
|
)
|
||||||
// }
|
|
||||||
//
|
|
||||||
// core.info(`Finalizing artifact upload`)
|
|
||||||
|
|
||||||
// const finalizeArtifactResp =
|
return {
|
||||||
// await artifactClient.FinalizeArtifact(finalizeArtifactReq)
|
size: uploadResult.uploadSize,
|
||||||
// if (!finalizeArtifactResp.ok) {
|
id: Number(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()) {
|
|
||||||
// setTimeout(function () {
|
|
||||||
// core.debug('Processes keeping upload stream running:')
|
|
||||||
// whyIsNodeRunning()
|
|
||||||
// }, 500)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
|
|
||||||
// )
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue