Skip to content

Instantly share code, notes, and snippets.

@Eunoia
Created November 19, 2014 17:43
Show Gist options
  • Save Eunoia/6d3b02c168764f273036 to your computer and use it in GitHub Desktop.
Save Eunoia/6d3b02c168764f273036 to your computer and use it in GitHub Desktop.
Deploy your wintersmith generated static site to amazon S3

Deploy wintersmith to S3

Simple as gulp deploy

This gist contains everything you need to start deploying your static site to Amazon S3.

We're using gulp as a task runner, and the run-wintersmith and gulp-s3 packages to build the site, and deploy to S3. This deploy task is very simple, and does not handle common taks like concatenation, minification, compressing images, or generating hashes of assets.

Getting Started

  1. Add package.json, aws.json, and Gulpfile.js to the root of your wintersmith site.
  2. Modify aws.json with your key, secret, bucketname(with the www), and region.
  3. Run npm install to get gulp, and the s3 library.

Usage

  1. Run gulp deploy to build your site, and push it to S3.
  2. Enjoy.
{
"key": "YOUR_AWS_KEY",
"secret": "YOUR_AWS_SECRET",
"bucket": "www.yourdomain.com",
"region": "us-west-1"
}
var fs = require('fs');
var gulp = require('gulp');
var runWintersmith = require('run-wintersmith');
var s3 = require("gulp-s3");
var options = { headers: {'Cache-Control': 'public'} }
gulp.task('default', function() {
console.log('`gulp deploy` to deploy')
});
gulp.task('deploy', function() {
runWintersmith.build(function(){
var aws = JSON.parse(fs.readFileSync('./aws.json'));
gulp.src('./build/**')
.pipe(s3(aws, options));
})
})
{
"dependencies": {
"moment": "2.3.x",
"run-wintersmith": "0.0.2",
"typogr": "0.5.x",
"underscore": "1.4.x"
},
"repository": "none",
"devDependencies": {
"gulp": "^3.8.10",
"gulp-s3": "^0.3.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment