Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add endpoint parameter #42

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ The following settings must be passed as environment variables as shown in the e
| `aws_bucket` | (Required) The name of the bucket you're upload to. |
| `source_dir` | (Required) The local directory (or file) you wish to upload to S3. The directory will replace to key generated by [shortid](https://github.com/dylang/shortid) in S3 |
| `destination_dir` | (Optional) The destination directory in S3<br />If this field is excluded a [shortid](https://github.com/dylang/shortid) will be generated |
| `endpoint` | (Optional) endpoint of the S3 instance |

> To upload to the root directory, set `destination_dir: ''` in `action.yml`

Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ inputs:
required: false
default: /
description: 'destination directory for upload'
endpoint:
required: false
description: 'endpoint of the s3 instance'
outputs:
object_key:
description: 'object key'
Expand Down
7 changes: 6 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ const shortid = require('shortid');
const klawSync = require('klaw-sync');
const { lookup } = require('mime-types');

const ENDPOINT = core.getInput('endpoint', {
required: false
});

const AWS_KEY_ID = core.getInput('aws_key_id', {
required: true
});
Expand All @@ -24,7 +28,8 @@ const DESTINATION_DIR = core.getInput('destination_dir', {

const s3 = new S3({
accessKeyId: AWS_KEY_ID,
secretAccessKey: SECRET_ACCESS_KEY
secretAccessKey: SECRET_ACCESS_KEY,
endpoint: ENDPOINT,
shallwefootball marked this conversation as resolved.
Show resolved Hide resolved
});
const destinationDir = DESTINATION_DIR === '/' ? shortid() : DESTINATION_DIR;
const paths = klawSync(SOURCE_DIR, {
Expand Down