From 0ec0dba5fc3c80b5c96b4597fdcf77593a289916 Mon Sep 17 00:00:00 2001 From: Akos Kitta Date: Thu, 2 Jul 2020 20:50:43 +0200 Subject: [PATCH] GH-9: Fixed type errors. - Log the `message` of the `Error` object. - Streamlined output to string for `fromjson`. - Aligned the documenation with the new `object_locations`value. Closes #9 Signed-off-by: Akos Kitta --- README.md | 8 ++++---- index.js | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index a6463236..8bc2a73c 100644 --- a/README.md +++ b/README.md @@ -81,7 +81,7 @@ The following settings must be passed as environment variables as shown in the e ## Action outputs -| name | description | -| ------------------ | --------------------------------------------------------------------------------------- | -| `object_key` | Uploaded object key generated by [shortid](https://github.com/dylang/shortid) in Bucket | -| `object_locations` | Object Locations | +| name | description | +| ------------------ | --------------------------------------------------------------------------------------------- | +| `object_key` | Uploaded object key generated by [shortid](https://github.com/dylang/shortid) in Bucket | +| `object_locations` | The URLs of the uploaded objects as a JSON string. E.g: `["location/file1","location/file2"]` | diff --git a/index.js b/index.js index b1b6162f..4f213d4c 100644 --- a/index.js +++ b/index.js @@ -1,3 +1,4 @@ +// @ts-check const core = require('@actions/core'); const S3 = require('aws-sdk/clients/s3'); const fs = require('fs'); @@ -34,7 +35,7 @@ const paths = klawSync(SOURCE_DIR, { function upload(params) { return new Promise(resolve => { s3.upload(params, (err, data) => { - if (err) core.error(err); + if (err) core.error(err.message); core.info(`uploaded - ${data.Key}`); core.info(`located - ${data.Location}`); resolve(data.Location); @@ -63,7 +64,7 @@ run() core.info(`object key - ${objKey}`); core.info(`object locations - ${locations}`); core.setOutput('object_key', objKey); - core.setOutput('object_locations', locations); + core.setOutput('object_locations', JSON.stringify(locations)); }) .catch(err => { core.error(err);