Skip to content

Commit

Permalink
update to latest toolkit version
Browse files Browse the repository at this point in the history
  • Loading branch information
n-g committed Feb 26, 2024
1 parent c90ed25 commit 1c4ce4a
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 7 deletions.
18 changes: 15 additions & 3 deletions dist/merge/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)();
Expand All @@ -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.`);
}
Expand Down Expand Up @@ -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,
Expand Down
18 changes: 15 additions & 3 deletions dist/upload/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)();
Expand All @@ -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.`);
}
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 1c4ce4a

Please sign in to comment.