--- version: 2 jobs: test: docker: - image: cibuilds/hugo:latest steps: - checkout # 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: name: Build HTML files command: HUGO_ENV=production hugo -v --minify - run: name: Test generated HTML files command: | htmlproofer public --allow-hash-href --check-html \ --empty-alt-ignore --disable-external - persist_to_workspace: root: . paths: - public - config - themes lint: docker: - image: cimg/python:3.9 steps: - checkout - run: name: Install pre-commit command: pip install pre-commit - run: name: Setup pre-commit cache key command: | cp .pre-commit-config.yaml pre-commit-cache-key.txt # Intentionally supplying --version twice to get verbose version information python --version --version >> pre-commit-cache-key.txt - restore_cache: keys: - v1-pre-commit-cache-{{ checksum "pre-commit-cache-key.txt" }} - run: name: Run pre-commit hooks command: pre-commit run --from-ref main --to-ref HEAD - save_cache: key: v1-pre-commit-cache-{{ checksum "pre-commit-cache-key.txt" }} paths: - ~/.cache/pre-commit 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: | sudo apt update sudo apt install python3-pip pip3 install awscli - deploy: name: Deploy to AWS command: | 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 - lint - deploy: context: aws-context requires: - test - lint filters: branches: only: - main