Updated CI config to deploy on commits to main
Part of a rename from master to main for the default branch.
This commit is contained in:
parent
663416b0f4
commit
144fc077e9
|
@ -1,36 +1,69 @@
|
||||||
|
---
|
||||||
version: 2
|
version: 2
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
test:
|
||||||
docker:
|
docker:
|
||||||
- image: cibuilds/hugo:latest
|
- image: cibuilds/hugo:latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
# clone repo
|
|
||||||
- checkout
|
- checkout
|
||||||
- run: git submodule sync && git submodule update --init
|
|
||||||
|
# TODO: Uncomment below two lines and install git further up if submodules end up being added
|
||||||
|
# install git submodules for managing third-part dependencies
|
||||||
|
# - run: git submodule sync && git submodule update --init
|
||||||
|
|
||||||
- run:
|
- run:
|
||||||
name: install AWS CLI
|
name: Build HTML files
|
||||||
command: |
|
command: HUGO_ENV=production hugo -v --minify
|
||||||
sudo apt update
|
|
||||||
sudo apt install python3-pip
|
|
||||||
pip3 install awscli
|
|
||||||
|
|
||||||
# build with hugo
|
|
||||||
- run: HUGO_ENV=production hugo -v --minify
|
|
||||||
- run:
|
- run:
|
||||||
name: Test generated HTML files
|
name: Test generated HTML files
|
||||||
command: |
|
command: |
|
||||||
htmlproofer public --allow-hash-href --check-html \
|
htmlproofer public --allow-hash-href --check-html \
|
||||||
--empty-alt-ignore --disable-external
|
--empty-alt-ignore --disable-external
|
||||||
|
|
||||||
- deploy:
|
- persist_to_workspace:
|
||||||
name: deploy to AWS
|
root: .
|
||||||
|
paths:
|
||||||
|
- public
|
||||||
|
- config
|
||||||
|
- themes
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
docker:
|
||||||
|
- image: cibuilds/hugo:latest
|
||||||
|
environment:
|
||||||
|
PROD_DEPLOY_CONFIG_PATH: config/production/deployment.toml
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- attach_workspace:
|
||||||
|
at: .
|
||||||
|
|
||||||
|
- run:
|
||||||
|
name: Install AWS CLI
|
||||||
command: |
|
command: |
|
||||||
if [ "${CIRCLE_BRANCH}" = "master" ]; then
|
sudo apt update
|
||||||
export PROD_DEPLOY_CONFIG_PATH="config/production/deployment.toml"
|
sudo apt install python3-pip
|
||||||
sed "s~{{S3URL}}~${S3URL}~g" "${PROD_DEPLOY_CONFIG_PATH}.sample" > "${PROD_DEPLOY_CONFIG_PATH}"
|
pip3 install awscli
|
||||||
sed -i "s~{{CLOUDFRONTDISTRIBUTIONID}}~${CLOUDFRONTDISTRIBUTIONID}~g" "${PROD_DEPLOY_CONFIG_PATH}"
|
|
||||||
HUGO_ENV=production hugo deploy --invalidateCDN
|
- deploy:
|
||||||
else
|
name: Deploy to AWS
|
||||||
echo "Not master branch, not deploying"
|
command: |
|
||||||
fi
|
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
|
||||||
|
|
||||||
|
workflows:
|
||||||
|
version: 2
|
||||||
|
main-workflow:
|
||||||
|
jobs:
|
||||||
|
- test
|
||||||
|
|
||||||
|
- deploy:
|
||||||
|
context: aws-context
|
||||||
|
requires:
|
||||||
|
- test
|
||||||
|
filters:
|
||||||
|
branches:
|
||||||
|
only:
|
||||||
|
- main
|
||||||
|
|
Loading…
Reference in a new issue