mirror of
https://github.com/actions/download-artifact.git
synced 2025-07-27 00:48:28 +02:00
attempting to make this a bit less error prone
Signed-off-by: Eli Uriegas <eliuriegas@fb.com>
This commit is contained in:
parent
5a1313076c
commit
10ec34d92d
2 changed files with 61 additions and 40 deletions
67
dist/index.js
vendored
67
dist/index.js
vendored
|
@ -19,7 +19,13 @@ module.exports =
|
||||||
/******/ };
|
/******/ };
|
||||||
/******/
|
/******/
|
||||||
/******/ // Execute the module function
|
/******/ // Execute the module function
|
||||||
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
/******/ var threw = true;
|
||||||
|
/******/ try {
|
||||||
|
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
||||||
|
/******/ threw = false;
|
||||||
|
/******/ } finally {
|
||||||
|
/******/ if(threw) delete installedModules[moduleId];
|
||||||
|
/******/ }
|
||||||
/******/
|
/******/
|
||||||
/******/ // Flag the module as loaded
|
/******/ // Flag the module as loaded
|
||||||
/******/ module.l = true;
|
/******/ module.l = true;
|
||||||
|
@ -5444,6 +5450,7 @@ module.exports = {"metadata":{"apiVersion":"2017-07-25","endpointPrefix":"dataex
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.Outputs = exports.Inputs = void 0;
|
||||||
var Inputs;
|
var Inputs;
|
||||||
(function (Inputs) {
|
(function (Inputs) {
|
||||||
Inputs["Name"] = "name";
|
Inputs["Name"] = "name";
|
||||||
|
@ -24755,7 +24762,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
||||||
var request = __webpack_require__(1753);
|
var request = __webpack_require__(1753);
|
||||||
var universalUserAgent = __webpack_require__(6796);
|
var universalUserAgent = __webpack_require__(6796);
|
||||||
|
|
||||||
const VERSION = "4.6.1";
|
const VERSION = "4.6.2";
|
||||||
|
|
||||||
class GraphqlError extends Error {
|
class GraphqlError extends Error {
|
||||||
constructor(request, response) {
|
constructor(request, response) {
|
||||||
|
@ -29851,6 +29858,7 @@ exports.getInput = getInput;
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
function setOutput(name, value) {
|
function setOutput(name, value) {
|
||||||
|
process.stdout.write(os.EOL);
|
||||||
command_1.issueCommand('set-output', { name }, value);
|
command_1.issueCommand('set-output', { name }, value);
|
||||||
}
|
}
|
||||||
exports.setOutput = setOutput;
|
exports.setOutput = setOutput;
|
||||||
|
@ -31120,6 +31128,25 @@ exports.getUserAgent = getUserAgent;
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||||
|
}) : (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
o[k2] = m[k];
|
||||||
|
}));
|
||||||
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
|
}) : function(o, v) {
|
||||||
|
o["default"] = v;
|
||||||
|
});
|
||||||
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
|
if (mod && mod.__esModule) return mod;
|
||||||
|
var result = {};
|
||||||
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
|
__setModuleDefault(result, mod);
|
||||||
|
return result;
|
||||||
|
};
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
|
@ -31129,13 +31156,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
|
||||||
if (mod && mod.__esModule) return mod;
|
|
||||||
var result = {};
|
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
||||||
result["default"] = mod;
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
|
@ -31165,27 +31185,30 @@ function run() {
|
||||||
core.debug(`Resolved path is ${resolvedPath}`);
|
core.debug(`Resolved path is ${resolvedPath}`);
|
||||||
const s3 = new AWS.S3();
|
const s3 = new AWS.S3();
|
||||||
const s3Prefix = `${github.context.repo.owner}/${github.context.repo.repo}/${github.context.runId}/${name}`;
|
const s3Prefix = `${github.context.repo.owner}/${github.context.repo.repo}/${github.context.runId}/${name}`;
|
||||||
s3.listObjects({ Bucket: s3Bucket, Prefix: s3Prefix }, function (err, data) {
|
const s3Params = {
|
||||||
if (!data.Contents || err) {
|
Bucket: s3Bucket,
|
||||||
core.error(err);
|
Prefix: s3Prefix
|
||||||
return;
|
};
|
||||||
|
core.debug(JSON.stringify(s3Params));
|
||||||
|
s3.listObjects(s3Params, function (err, data) {
|
||||||
|
if (err) {
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
if (!data.Contents) {
|
||||||
|
throw new Error(`Could not find objects with ${s3Prefix}`);
|
||||||
}
|
}
|
||||||
for (const fileObject of data.Contents) {
|
for (const fileObject of data.Contents) {
|
||||||
if (!fileObject.Key) {
|
if (!fileObject.Key) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
const getObjectParams = { Bucket: s3Bucket, Key: fileObject.Key };
|
||||||
const localKey = fileObject.Key.replace(s3Prefix, '');
|
const localKey = fileObject.Key.replace(s3Prefix, '');
|
||||||
|
const writeStream = fs.createWriteStream(localKey);
|
||||||
core.info(`Started download: ${localKey}`);
|
core.info(`Started download: ${localKey}`);
|
||||||
core.debug(`S3 download uri: s3://${s3Bucket}/${fileObject.Key}`);
|
core.debug(`S3 download uri: s3://${s3Bucket}/${fileObject.Key}`);
|
||||||
s3.getObject({ Bucket: s3Bucket, Key: fileObject.Key }, function (err, fileContents) {
|
const readStream = s3.getObject(getObjectParams).createReadStream();
|
||||||
var _a;
|
readStream.pipe(writeStream);
|
||||||
if (err) {
|
core.info(`Finished download for ${localKey}`);
|
||||||
core.error(`Error downloading ${localKey}`);
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
fs.writeFileSync(path_1.default.join(resolvedPath, localKey), (_a = fileContents.Body) === null || _a === void 0 ? void 0 : _a.toString());
|
|
||||||
core.info(`Done: ${localKey}`);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// output the directory that the artifact(s) was/were downloaded to
|
// output the directory that the artifact(s) was/were downloaded to
|
||||||
|
|
|
@ -23,32 +23,30 @@ async function run(): Promise<void> {
|
||||||
core.debug(`Resolved path is ${resolvedPath}`)
|
core.debug(`Resolved path is ${resolvedPath}`)
|
||||||
const s3 = new AWS.S3()
|
const s3 = new AWS.S3()
|
||||||
const s3Prefix = `${github.context.repo.owner}/${github.context.repo.repo}/${github.context.runId}/${name}`
|
const s3Prefix = `${github.context.repo.owner}/${github.context.repo.repo}/${github.context.runId}/${name}`
|
||||||
s3.listObjects({Bucket: s3Bucket, Prefix: s3Prefix}, function (err, data) {
|
const s3Params = {
|
||||||
if (!data.Contents || err) {
|
Bucket: s3Bucket,
|
||||||
core.error(err)
|
Prefix: s3Prefix
|
||||||
return
|
}
|
||||||
|
core.debug(JSON.stringify(s3Params))
|
||||||
|
s3.listObjects(s3Params, function (err, data) {
|
||||||
|
if (err) {
|
||||||
|
throw err
|
||||||
|
}
|
||||||
|
if (!data.Contents) {
|
||||||
|
throw new Error(`Could not find objects with ${s3Prefix}`)
|
||||||
}
|
}
|
||||||
for (const fileObject of data.Contents) {
|
for (const fileObject of data.Contents) {
|
||||||
if (!fileObject.Key) {
|
if (!fileObject.Key) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
const getObjectParams = {Bucket: s3Bucket, Key: fileObject.Key}
|
||||||
const localKey = fileObject.Key.replace(s3Prefix, '')
|
const localKey = fileObject.Key.replace(s3Prefix, '')
|
||||||
|
const writeStream = fs.createWriteStream(localKey)
|
||||||
core.info(`Started download: ${localKey}`)
|
core.info(`Started download: ${localKey}`)
|
||||||
core.debug(`S3 download uri: s3://${s3Bucket}/${fileObject.Key}`)
|
core.debug(`S3 download uri: s3://${s3Bucket}/${fileObject.Key}`)
|
||||||
s3.getObject({Bucket: s3Bucket, Key: fileObject.Key}, function (
|
const readStream = s3.getObject(getObjectParams).createReadStream()
|
||||||
err,
|
readStream.pipe(writeStream)
|
||||||
fileContents
|
core.info(`Finished download for ${localKey}`)
|
||||||
) {
|
|
||||||
if (err) {
|
|
||||||
core.error(`Error downloading ${localKey}`)
|
|
||||||
throw err
|
|
||||||
}
|
|
||||||
fs.writeFileSync(
|
|
||||||
path.join(resolvedPath, localKey),
|
|
||||||
fileContents.Body?.toString()
|
|
||||||
)
|
|
||||||
core.info(`Done: ${localKey}`)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
// output the directory that the artifact(s) was/were downloaded to
|
// output the directory that the artifact(s) was/were downloaded to
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue