Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
CircleCI config for damieng.com
version: 2
jobs:
build:
docker:
- image: circleci/ruby:2.3
working_directory: ~/jekyll
environment:
- JEKYLL_ENV=production
- NOKOGIRI_USE_SYSTEM_LIBRARIES=true
- JOB_RESULTS_PATH=run-results
steps:
- checkout
- restore_cache:
key: jekyll-{{ .Branch }}-{{ checksum "Gemfile.lock" }}
- run:
name: Install dependencies
command: bundle check --path=vendor/bundle || bundle install --path=vendor/bundle --jobs=4 --retry=3
- save_cache:
key: jekyll-{{ .Branch }}-{{ checksum "Gemfile.lock" }}
paths:
- "vendor/bundle"
- run:
name: Create results directory
command: mkdir -p $JOB_RESULTS_PATH
- run:
name: Build site
command: bundle exec jekyll build 2>&1 | tee $JOB_RESULTS_PATH/build-results.txt
- run:
name: Remove .html suffixes
command: find _site -name "*.html" -not -name "index.html" -exec rename -v 's/\.html$//' {} \;
- run:
name: Index with Algolia
command: bundle exec jekyll algolia
- store_artifacts:
path: run-results/
destination: run-results
- persist_to_workspace:
root: ~/jekyll
paths:
- _site
deploy:
docker:
- image: circleci/python:2.7
working_directory: ~/jekyll
steps:
- attach_workspace:
at: ~/jekyll
- run:
name: Install awscli
command: sudo pip install awscli
- run:
name: Deploy to S3
command: aws s3 sync _site s3://damieng-static/ --delete --content-type=text/html
- run:
name: Correct MIME for robots.txt automatically
command: aws s3 cp s3://damieng-static/robots.txt s3://damieng-static/robots.txt --metadata-directive="REPLACE"
- run:
name: Correct MIME for sitemap.xml automatically
command: aws s3 cp s3://damieng-static/sitemap.xml s3://damieng-static/sitemap.xml --metadata-directive="REPLACE"
- run:
name: Correct MIME for Atom feed manually
command: aws s3 cp s3://damieng-static/feed.xml s3://damieng-static/feed.xml --no-guess-mime-type --content-type="application/atom+xml" --metadata-directive="REPLACE"
- run:
name: Redirect /damieng for existing RSS subscribers
command: aws s3api put-object --bucket damieng-static --key "damieng" --website-redirect-location "https://damieng.com/feed.xml"
- run:
name: Latest Envy Code R redirect
command: aws s3api put-object --bucket damieng-static --key "envy-code-r" --website-redirect-location "https://damieng.com/blog/2008/05/26/envy-code-r-preview-7-coding-font-released"
- run:
name: Correct MIME for CSS files
command: |
aws s3 cp s3://damieng-static/css/damieng.css s3://damieng-static/css/damieng.css --metadata-directive="REPLACE"
aws s3 cp s3://damieng-static/css/dracula.css s3://damieng-static/css/dracula.css --metadata-directive="REPLACE"
workflows:
version: 2
build-deploy:
jobs:
- build
- deploy:
requires:
- build
filters:
branches:
only: master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment