Skip to content

Commit

Permalink
remove endpoint url and add locations
Browse files Browse the repository at this point in the history
  • Loading branch information
shallwefootball committed Mar 18, 2020
1 parent 8fe800a commit 742ee30
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 24 deletions.
12 changes: 4 additions & 8 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,11 @@ inputs:
source_dir:
required: true
description: 'directory to upload'
s3_endpoint_url:
required: true
description: 's3 endpoint url'
index_document:
required: false
description: 'default index.html'
outputs:
object_url:
description: 'object url'
object_key:
description: 'object key'
object_locations:
description: 'object locations'
runs:
using: 'node12'
main: 'dist/index.js'
Expand Down
15 changes: 7 additions & 8 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2408,9 +2408,6 @@ const SECRET_ACCESS_KEY = core.getInput('aws_secret_access_key', {
});
const BUCKET = core.getInput('aws_bucket', { required: true });
const SOURCE_DIR = core.getInput('source_dir', { required: true });
const ENDPOINT_URL = core.getInput('s3_endpoint_url', { required: true });
const INDEX =
core.getInput('index_document', { required: false }) || 'index.html';

const s3 = new S3({
accessKeyId: AWS_KEY_ID,
Expand All @@ -2424,7 +2421,8 @@ function upload(params) {
s3.upload(params, (err, data) => {
if (err) core.error(err);
core.info(`uploaded - ${data.Key}`);
resolve();
core.info(`located - ${data.Location}`);
resolve(data.Location);
});
});
}
Expand All @@ -2446,10 +2444,11 @@ function run() {
}

run()
.then(() => {
const url = path.join(ENDPOINT_URL, objKey, INDEX);
core.info(`object url - ${url}`);
core.setOutput('object_url', url);
.then(locations => {
core.info(`object key - ${objKey}`);
core.info(`object locations - ${locations}`);
core.setOutput('object_key', objKey);
core.setOutput('object_locations', locations);
})
.catch(err => {
core.error(err);
Expand Down
15 changes: 7 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ const SECRET_ACCESS_KEY = core.getInput('aws_secret_access_key', {
});
const BUCKET = core.getInput('aws_bucket', { required: true });
const SOURCE_DIR = core.getInput('source_dir', { required: true });
const ENDPOINT_URL = core.getInput('s3_endpoint_url', { required: true });
const INDEX =
core.getInput('index_document', { required: false }) || 'index.html';

const s3 = new S3({
accessKeyId: AWS_KEY_ID,
Expand All @@ -28,7 +25,8 @@ function upload(params) {
s3.upload(params, (err, data) => {
if (err) core.error(err);
core.info(`uploaded - ${data.Key}`);
resolve();
core.info(`located - ${data.Location}`);
resolve(data.Location);
});
});
}
Expand All @@ -50,10 +48,11 @@ function run() {
}

run()
.then(() => {
const url = path.join(ENDPOINT_URL, objKey, INDEX);
core.info(`object url - ${url}`);
core.setOutput('object_url', url);
.then(locations => {
core.info(`object key - ${objKey}`);
core.info(`object locations - ${locations}`);
core.setOutput('object_key', objKey);
core.setOutput('object_locations', locations);
})
.catch(err => {
core.error(err);
Expand Down

0 comments on commit 742ee30

Please sign in to comment.