Skip to content

Commit

Permalink
Merge pull request #51 from shallwefootball/feature/endpoint
Browse files Browse the repository at this point in the history
add option endpoint
  • Loading branch information
shallwefootball authored Feb 11, 2023
2 parents 673c5bb + 5320377 commit 03f642a
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 10 deletions.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,14 @@ jobs:
The following settings must be passed as environment variables as shown in the example. Sensitive information, especially `aws_key_id` and `aws_secret_access_key`, should be [set as encrypted secrets](https://help.github.com/en/articles/virtual-environments-for-github-actions#creating-and-using-secrets-encrypted-variables) — otherwise, they'll be public to anyone browsing your repository's source code

| name | description |
| ----------------------- | ------------------------------------------------------------ |
| `aws_key_id` | (Required) Your AWS Access Key. [More info here.](https://docs.aws.amazon.com/general/latest/gr/managing-aws-access-keys.html) |
| `aws_secret_access_key` | (Required) Your AWS Secret Access Key. [More info here.](https://docs.aws.amazon.com/general/latest/gr/managing-aws-access-keys.html) |
| `aws_bucket` | (Required) The name of the bucket you're upload to. |
| name | description |
|-------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `aws_key_id` | (Required) Your AWS Access Key. [More info here.](https://docs.aws.amazon.com/general/latest/gr/managing-aws-access-keys.html) |
| `aws_secret_access_key` | (Required) Your AWS Secret Access Key. [More info here.](https://docs.aws.amazon.com/general/latest/gr/managing-aws-access-keys.html) |
| `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 |
| `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) The endpoint URI to send requests to. [More info here.](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html) |

> 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 URI to send requests'
outputs:
object_key:
description: 'object key'
Expand Down
13 changes: 11 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28862,11 +28862,20 @@ const SOURCE_DIR = core.getInput('source_dir', {
const DESTINATION_DIR = core.getInput('destination_dir', {
required: false
});
const ENDPOINT = core.getInput('endpoint', {
required: false
});

const s3 = new S3({
const s3options = {
accessKeyId: AWS_KEY_ID,
secretAccessKey: SECRET_ACCESS_KEY
});
}

if (ENDPOINT) {
s3options.endpoint = ENDPOINT
}

const s3 = new S3(s3options);
const destinationDir = DESTINATION_DIR === '/' ? shortid() : DESTINATION_DIR;
const paths = klawSync(SOURCE_DIR, {
nodir: true
Expand Down
13 changes: 11 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,20 @@ const SOURCE_DIR = core.getInput('source_dir', {
const DESTINATION_DIR = core.getInput('destination_dir', {
required: false
});
const ENDPOINT = core.getInput('endpoint', {
required: false
});

const s3 = new S3({
const s3options = {
accessKeyId: AWS_KEY_ID,
secretAccessKey: SECRET_ACCESS_KEY
});
}

if (ENDPOINT) {
s3options.endpoint = ENDPOINT
}

const s3 = new S3(s3options);
const destinationDir = DESTINATION_DIR === '/' ? shortid() : DESTINATION_DIR;
const paths = klawSync(SOURCE_DIR, {
nodir: true
Expand Down

0 comments on commit 03f642a

Please sign in to comment.