Created
February 10, 2018 19:59
-
-
Save derikwhittaker/c9a8872ed03f3df4410008dda95c08e5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const gulp = require('gulp'); | |
const run = require('gulp-run'); | |
const replace = require('gulp-replace'); | |
const runSequence = require('run-sequence'); | |
const log = require('fancy-log'); | |
const AWS = require('aws-sdk'); | |
const s3 = new AWS.S3({apiVersion: '2006-03-01'}); | |
const s3Options = { | |
bucketName: "my-bucket-name" | |
}; | |
const siteOptions = { | |
buildFolder: "./build", | |
deployFileName: "build.zip" | |
} | |
gulp.task('default', ['deploy-test']); | |
gulp.task('build-react', buildReact) | |
gulp.task('update-config-values', updateConfigValues); | |
gulp.task('copy-to-bucket', copyToS3Bucket); | |
gulp.task('deploy-test', function(done){ | |
s3Options.bucketName = "my-bucket-name-test"; | |
// we use runSequence to ensure that our tasks | |
// sync vs asynch | |
runSequence( 'update-config-values', | |
'build-react', | |
'copy-to-bucket', | |
done); | |
}); | |
function buildReact() { | |
log.info("Attempting build the application, this may take 30-60 seconds") | |
return run("npm run build").exec(); | |
} | |
function copyToS3Bucket() { | |
const pathToS3Bucket = "s3://" + s3Options.bucketName; | |
// I am using the --recurisve here in order top copy all the files in my build folder | |
const publishPackageCommand = "aws s3 cp " + siteOptions.buildFolder + " " + pathToS3Bucket + " --recursive"; | |
return run(publishPackageCommand).exec(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment