UNPKG

ci-scripts

Version:

Useful scripts to execute from your CI runner. For example, post to Slack and GitHub when your build completes:

41 lines (34 loc) 1.44 kB
/* eslint-disable filenames/match-exported */ const s3UploadDir = require('../effects/s3UploadDir'); /// Uploads a folder and all its files recursively to a destination /// in a S3 bucket. const s3Upload = (ci) => { const {params} = ci; const bucket = params.bucket; const src = params.localDir || 'dist/'; if (!bucket || (typeof bucket !== 'string')) { throw new TypeError('Bucket not specified or not a string.'); } if (!src || (typeof src !== 'string')) { throw new TypeError('Directory not specified or not a string.'); } /// - `--accessKeyId` — optional, AWS access key id. /// - `--secretAccessKey` — optional, AWS secrekt key. /// - `--src` — optional, source folder to upload, defaults to `dist/`. /// - `--bucket` — required, S3 bucket name. /// - `--dest` — optional, S3 destination path, defaults to '""'. /// - `--acl` — optional, access rights to all uploaded objects. /// - `--delete` — optional, whether to delete old files on S3, defaults to `false`. const config = { accessKeyId: params.accessKeyId, secretAccessKey: params.secretAccessKey, region: params.region, src, bucket, dest: params.dest || '', acl: params.acl || undefined, delete: Boolean(params.delete), }; return s3UploadDir(ci, config); }; module.exports = s3Upload;