This project demonstrates how to continuously deploy a Jekyll site to S3 via CircleCI.
- Initialize a new GitHub repo containing a Jekyll site, like this repo
- Add
.circleci/config.yml
to the repo (see below for example) - (Optional but recommended) Create a separate AWS IAM account for hosting the S3 site
- Obtain an AWS access key via IAM
- Create a new S3 bucket to host the site
- Configure the S3 bucket properties to enable static website hosting
- Add an AWS policy to the bucket allowing public
s3:GetObject
access (see below for example) - Add a new project in CircleCI and select your GitHub repo
- Configure the CircleCI project environment variables to add:
AWS_ACCESS_KEY_ID
- from IAMAWS_SECRET_ACCESS_KEY
- from IAMAWS_REGION
- your default AWS region
At this point, CircleCI should automatically build and deploy any changes you push to the master
branch.
version: 2.1
orbs:
ruby: circleci/ruby@0.2.2
s3: circleci/aws-s3@1.0.15
jobs:
build:
docker:
- image: circleci/ruby:2.6.5
steps:
- checkout
- run:
name: Install bundler
command: gem install bundler
- ruby/load-cache
- ruby/install-deps
- ruby/save-cache
- run:
name: Jekyll build
command: BUNDLE_PATH=vendor/bundle bundle exec jekyll build
- persist_to_workspace:
root: .
paths:
- _site
deploy:
docker:
- image: circleci/python:3.6
steps:
- attach_workspace:
at: .
- s3/sync:
from: _site
overwrite: true
to: 's3://YOUR_BUCKET_NAME_HERE/'
workflows:
continuous_deployment:
jobs:
- build
- deploy:
requires:
- build
{
"Version": "2012-10-17",
"Id": "s3BucketPolicy",
"Statement": [
{
"Sid": "allowPublicAccess",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::YOUR_BUCKET_NAME_HERE/*"
}
]
}