diff --git a/README.md b/README.md index 0df7e55..bab5dc5 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +EDITED by ZabasJC + # s3-upload-github-action S3 uploader for Github Actions. @@ -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 }} diff --git a/index.js b/index.js index fa783dc..1e261a5 100644 --- a/index.js +++ b/index.js @@ -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; @@ -38,4 +48,7 @@ const uploadFile = (fileName) => { } }; -uploadFile(process.env.FILE); +const array = (process.env.FILE).split(" "); +array.forEach((file) => { + uploadFile(file); +})