Add initial CircleCI build

pull/13/head
Gunnar Aasen 2019-01-18 12:53:09 -08:00
parent 22304dfe58
commit ca836ce728
4 changed files with 92 additions and 0 deletions

62
.circleci/config.yml Normal file
View File

@ -0,0 +1,62 @@
version: 2
jobs:
build:
docker:
- image: circleci/golang:latest
environment:
HUGO_VERSION: "0.53"
S3DEPLOY_VERSION: "2.3.0"
steps:
- checkout
- restore_cache:
keys:
- install-v1-{{ checksum ".circleci/config.yml" }}
- install-v1-
- run:
name: Make bin folder
command: mkdir -p $HOME/bin
- run:
name: Install Hugo
command: ./deploy/ci-install-hugo.sh
- run:
name: Install s3deploy
command: ./deploy/ci-install-s3deploy.sh
- save_cache:
key: install-v1-{{ checksum ".circleci/config.yml" }}
paths:
- /home/circleci/bin
- run:
name: Hugo Build
command: $HOME/bin/hugo -v --destination workspace/public
- persist_to_workspace:
root: workspace
paths:
- public
deploy:
docker:
- image: circleci/golang:latest
steps:
- checkout
- restore_cache:
keys:
- install-v1-{{ checksum ".circleci/config.yml" }}
- install-v1-
- attach_workspace:
at: workspace
- run:
name: Deploy to S3
command: $HOME/bin/s3deploy -source=workspace/public/ -bucket=$BUCKET -region=$REGION
workflows:
version: 2
build:
jobs:
- build
- deploy:
requires:
- build
filters:
branches:
only:
- ga-cf-templates

8
.s3deploy.yml Normal file
View File

@ -0,0 +1,8 @@
routes:
- route: "^.+\\.(js|css|svg|ttf|png|jpg)$"
# cache static assets for 20 years
headers:
Cache-Control: "max-age=630720000, no-transform, public"
gzip: true
- route: "^.+\\.(html|xml|json|js)$"
gzip: true

11
deploy/ci-install-hugo.sh Normal file
View File

@ -0,0 +1,11 @@
HUGO_DOWNLOAD=hugo_extended_${HUGO_VERSION}_Linux-64bit.tar.gz
set -x
set -e
# Install Hugo if not already cached or upgrade an old version.
if [ ! -e $HOME/bin/hugo ] || ! [[ `$HOME/bin/hugo version` =~ v${HUGO_VERSION} ]]; then
wget https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/${HUGO_DOWNLOAD}
tar xvzf ${HUGO_DOWNLOAD} hugo
mv hugo $HOME/bin/hugo
fi

View File

@ -0,0 +1,11 @@
S3DEPLOY_DOWNLOAD=s3deploy_${S3DEPLOY_VERSION}_Linux-64bit.tar.gz
set -x
set -e
# Install s3deploy if not already cached or upgrade an old version.
if [ ! -e $HOME/bin/s3deploy ] || ! [[ `$HOME/bin/s3deploy -V` =~ ${S3DEPLOY_VERSION} ]]; then
wget https://github.com/bep/s3deploy/releases/download/v${S3DEPLOY_VERSION}/${S3DEPLOY_DOWNLOAD}
tar xvzf ${S3DEPLOY_DOWNLOAD} s3deploy
mv s3deploy $HOME/bin/s3deploy
fi