Skip to content
Open
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
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
EDITED by ZabasJC

# s3-upload-github-action

S3 uploader for Github Actions.
Expand All @@ -23,7 +25,8 @@ jobs:
- name: Upload file to bucket
uses: koraykoska/s3-upload-github-action@master
env:
FILE: ./releases/
FILE: ./releases/ # can handle a list of files divided by space
S3_PREFIX: 'whatever' # if blank, it will be skipped
S3_ENDPOINT: 'ams3.digitaloceanspaces.com'
S3_BUCKET: ${{ secrets.S3_BUCKET }}
S3_ACCESS_KEY_ID: ${{ secrets.S3_ACCESS_KEY_ID }}
Expand Down
25 changes: 19 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,21 @@ const uploadFile = (fileName) => {
const fileContent = fs.readFileSync(fileName);

// Setting up S3 upload parameters
const params = {
Bucket: process.env.S3_BUCKET,
Key: `${process.env.S3_PREFIX || ""}/${path.normalize(fileName)}`,
Body: fileContent,
};

if (process.env.S3_PREFIX == '') {
var params = {
Bucket: process.env.S3_BUCKET,
Key: `${path.normalize(fileName)}`,
Body: fileContent,
};
} else {
var params = {
Bucket: process.env.S3_BUCKET,
Key: `${process.env.S3_PREFIX || ""}/${path.normalize(fileName)}`,
Body: fileContent,
};
}

const acl = process.env.S3_ACL;
if (acl) {
params.ACL = acl;
Expand All @@ -38,4 +48,7 @@ const uploadFile = (fileName) => {
}
};

uploadFile(process.env.FILE);
const array = (process.env.FILE).split(" ");
array.forEach((file) => {
uploadFile(file);
})