From 4adaf86dcda4439487c2b54d913f246361ba5cb1 Mon Sep 17 00:00:00 2001 From: Alejandro Angulo Date: Fri, 17 Jul 2020 23:28:13 -0700 Subject: [PATCH] Circleci project setup (#1) --- .circleci/config.yml | 36 ++++++++++++++++++++++++ config/production/deployment.toml.sample | 4 +-- 2 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..6b2025d --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,36 @@ +version: 2 +jobs: + build: + docker: + - image: cibuilds/hugo:latest + steps: + # clone repo + - checkout + - run: git submodule sync && git submodule update --init + + - run: + name: install AWS CLI + command: | + sudo apt update + sudo apt install python-pip + pip install awscli + + # build with hugo + - run: HUGO_ENV=production hugo -v + - run: + name: Test generated HTML files + command: | + htmlproofer public --allow-hash-href --check-html \ + --empty-alt-ignore --disable-external + + - deploy: + name: deploy to AWS + command: | + if [ "${CIRCLE_BRANCH}" = "master" ]; then + export PROD_DEPLOY_CONFIG_PATH="config/production/deployment.toml" + sed "s~{{S3URL}}~${S3URL}~g" "${PROD_DEPLOY_CONFIG_PATH}.sample" > "${PROD_DEPLOY_CONFIG_PATH}" + sed -i "s~{{CLOUDFRONTDISTRIBUTIONID}}~${CLOUDFRONTDISTRIBUTIONID}~g" "${PROD_DEPLOY_CONFIG_PATH}" + HUGO_ENV=production hugo deploy --invalidateCDN + else + echo "Not master branch, not deploying" + fi diff --git a/config/production/deployment.toml.sample b/config/production/deployment.toml.sample index e726144..ca22cbe 100644 --- a/config/production/deployment.toml.sample +++ b/config/production/deployment.toml.sample @@ -2,8 +2,8 @@ order = [".jpg$", ".gif$"] [[targets]] name = "aws-s3" -URL = "$S3URL" -cloudFrontDistributionID = "$cloudFrontDistributionID" +URL = "{{S3URL}}" +cloudFrontDistributionID = "{{CLOUDFRONTDISTRIBUTIONID}}" [[matchers]] # Cache static assets for 1 year.