CircleCI: Build static site with Hugo, Upload to S3
defaults: &defaults | |
working_directory: ~/work | |
docker: | |
- image: ubuntu:16.04 | |
version: 2 | |
jobs: | |
build: | |
<<: *defaults | |
steps: | |
- run: | |
name: APT update | |
command: apt update | |
- run: | |
name: Install curl | |
command: apt install -y curl | |
- run: | |
name: Install git | |
command: apt install -y git | |
- checkout | |
- run: git submodule update --init | |
- run: | |
name: Download Hugo | |
command: curl -LO 'https://github.com/gohugoio/hugo/releases/download/v0.36/hugo_0.36_Linux-64bit.deb' | |
- run: | |
name: Install Hugo | |
command: dpkg -i hugo_0.36_Linux-64bit.deb | |
- run: | |
name: Build Website | |
command: hugo | |
- persist_to_workspace: | |
root: . | |
paths: | |
- public | |
deploy: | |
<<: *defaults | |
steps: | |
- run: | |
name: APT update | |
command: apt update | |
- run: | |
name: Install ca-certificates for attach_workspace | |
command: apt install -y ca-certificates | |
- run: | |
name: Install pip3 | |
command: apt install -y python3-pip | |
- run: | |
name: Install AWS CLI | |
command: pip3 install awscli | |
- attach_workspace: | |
at: . | |
- run: | |
name: Deploy to S3 | |
command: aws s3 sync --exact-timestamps public/ s3://${S3_BUCKET_NAME}/ --delete | |
- run: | |
name: Invalidate CloudFront cache | |
command: aws cloudfront create-invalidation --distribution-id ${CLOUDFRONT_DISTRIBUTION_ID} --paths '/*' | |
workflows: | |
version: 2 | |
build_and_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