From 1c4ce4a37dd6bdf7cc198f918931e3c8ef7dc379 Mon Sep 17 00:00:00 2001 From: Niklas Gehlen Date: Mon, 26 Feb 2024 17:31:28 +0100 Subject: [PATCH] update to latest toolkit version --- actions-toolkit | 2 +- dist/merge/index.js | 18 +++++++++++++++--- dist/upload/index.js | 18 +++++++++++++++--- 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/actions-toolkit b/actions-toolkit index aab85850..8afa64e0 160000 --- a/actions-toolkit +++ b/actions-toolkit @@ -1 +1 @@ -Subproject commit aab85850f5192c3b8570e9a5d46c813247051165 +Subproject commit 8afa64e031b73b76a832665c1efd0498c5f5dc8b diff --git a/dist/merge/index.js b/dist/merge/index.js index 17cfde08..f4de8991 100644 --- a/dist/merge/index.js +++ b/dist/merge/index.js @@ -3401,8 +3401,9 @@ const config_1 = __nccwpck_require__(25597); const core = __importStar(__nccwpck_require__(12331)); const crypto = __importStar(__nccwpck_require__(6113)); const stream = __importStar(__nccwpck_require__(12781)); +const fs = __importStar(__nccwpck_require__(57147)); const errors_1 = __nccwpck_require__(37986); -function uploadZipToBlobStorage(authenticatedUploadURL, zipUploadStream) { +function uploadZipToBlobStorage(name, authenticatedUploadURL, zipUploadStream) { return __awaiter(this, void 0, void 0, function* () { let uploadByteCount = 0; const maxConcurrency = (0, config_1.getConcurrency)(); @@ -3425,8 +3426,19 @@ function uploadZipToBlobStorage(authenticatedUploadURL, zipUploadStream) { zipUploadStream.pipe(hashStream).setEncoding('hex'); // This stream is used to compute a hash of the zip content that gets used. Integrity check core.info('Beginning upload of artifact content to blob storage'); if ((0, config_1.directZipUpload)()) { + const tempDirectory = process.env['RUNNER_TEMP']; + if (!tempDirectory) { + throw new Error('Unable to get the RUNNER_TEMP env variable'); + } + // TODO encode the name to always have a valid filename. + const tempFile = tempDirectory + '/' + name + '.zip'; + const file = fs.createWriteStream(tempFile); + yield uploadStream.pipe(file); + const stat = fs.statSync(tempFile); const httpClient = new http_client_1.HttpClient('actions/artifact'); - const res = yield httpClient.sendStream('PUT', authenticatedUploadURL, uploadStream); + const res = yield httpClient.sendStream('PUT', authenticatedUploadURL, fs.createReadStream(tempFile), { + "Content-Length": stat.size + }); if (!res.message.statusCode || res.message.statusCode < 200 || res.message.statusCode >= 300) { throw new Error(`Service responded with ${res.message.statusCode} during artifact upload.`); } @@ -3674,7 +3686,7 @@ function uploadArtifact(name, files, rootDirectory, options) { } const zipUploadStream = yield (0, zip_1.createZipUploadStream)(zipSpecification, options === null || options === void 0 ? void 0 : options.compressionLevel); // Upload zip to blob storage - const uploadResult = yield (0, blob_upload_1.uploadZipToBlobStorage)(createArtifactResp.signedUploadUrl, zipUploadStream); + const uploadResult = yield (0, blob_upload_1.uploadZipToBlobStorage)(name, createArtifactResp.signedUploadUrl, zipUploadStream); // finalize the artifact const finalizeArtifactReq = { workflowRunBackendId: backendIds.workflowRunBackendId, diff --git a/dist/upload/index.js b/dist/upload/index.js index 04cfcf97..26d21c7e 100644 --- a/dist/upload/index.js +++ b/dist/upload/index.js @@ -3401,8 +3401,9 @@ const config_1 = __nccwpck_require__(25597); const core = __importStar(__nccwpck_require__(12331)); const crypto = __importStar(__nccwpck_require__(6113)); const stream = __importStar(__nccwpck_require__(12781)); +const fs = __importStar(__nccwpck_require__(57147)); const errors_1 = __nccwpck_require__(37986); -function uploadZipToBlobStorage(authenticatedUploadURL, zipUploadStream) { +function uploadZipToBlobStorage(name, authenticatedUploadURL, zipUploadStream) { return __awaiter(this, void 0, void 0, function* () { let uploadByteCount = 0; const maxConcurrency = (0, config_1.getConcurrency)(); @@ -3425,8 +3426,19 @@ function uploadZipToBlobStorage(authenticatedUploadURL, zipUploadStream) { zipUploadStream.pipe(hashStream).setEncoding('hex'); // This stream is used to compute a hash of the zip content that gets used. Integrity check core.info('Beginning upload of artifact content to blob storage'); if ((0, config_1.directZipUpload)()) { + const tempDirectory = process.env['RUNNER_TEMP']; + if (!tempDirectory) { + throw new Error('Unable to get the RUNNER_TEMP env variable'); + } + // TODO encode the name to always have a valid filename. + const tempFile = tempDirectory + '/' + name + '.zip'; + const file = fs.createWriteStream(tempFile); + yield uploadStream.pipe(file); + const stat = fs.statSync(tempFile); const httpClient = new http_client_1.HttpClient('actions/artifact'); - const res = yield httpClient.sendStream('PUT', authenticatedUploadURL, uploadStream); + const res = yield httpClient.sendStream('PUT', authenticatedUploadURL, fs.createReadStream(tempFile), { + "Content-Length": stat.size + }); if (!res.message.statusCode || res.message.statusCode < 200 || res.message.statusCode >= 300) { throw new Error(`Service responded with ${res.message.statusCode} during artifact upload.`); } @@ -3674,7 +3686,7 @@ function uploadArtifact(name, files, rootDirectory, options) { } const zipUploadStream = yield (0, zip_1.createZipUploadStream)(zipSpecification, options === null || options === void 0 ? void 0 : options.compressionLevel); // Upload zip to blob storage - const uploadResult = yield (0, blob_upload_1.uploadZipToBlobStorage)(createArtifactResp.signedUploadUrl, zipUploadStream); + const uploadResult = yield (0, blob_upload_1.uploadZipToBlobStorage)(name, createArtifactResp.signedUploadUrl, zipUploadStream); // finalize the artifact const finalizeArtifactReq = { workflowRunBackendId: backendIds.workflowRunBackendId,