redbrick/static-site

View on GitHub
.circleci/config.yml

Summary

Maintainability
Test Coverage
---
version: 2
jobs:
  build:
    working_directory: ~/static-site
    docker:
      - image: node:8
    steps:
      - checkout
      - restore_cache:
          key: dependency-cache-{{ checksum "yarn.lock" }}
      - run:
          name: Install Dep
          command: yarn
      - save_cache:
          key: dependency-cache-{{ checksum "yarn.lock" }}
          paths:
            - node_modules
      - run:
          name: Build Site
          command: |
            set -eo pipefail
            yarn generate
      - run:
          name: Get Cache Checksum
          command: ls -lnR source > deps_checksum
      - save_cache:
          key: build-cache-{{ .Branch }}-{{ checksum "deps_checksum" }}
          paths:
            - public
  test:
    docker:
      - image: 18fgsa/html-proofer
        environment:
          ENV: CI
    working_directory: ~/static-site
    steps:
      - checkout
      - run:
          name: Get Cache Checksum
          command: ls -lnR source > deps_checksum
      - restore_cache:
          keys:
            - build-cache-{{ .Branch }}-{{ checksum "deps_checksum" }}
            - build-cache-{{ .Branch }}
      - run:
          name: Test Internal Links
          command: |
            set -eo pipefail
            htmlproofer --allow-hash-href --check-html --empty-alt-ignore \
              --disable-external ~/static-site/public
      - store_artifacts:
          path: results.txt
          prefix: tests
      - store_test_results:
          path: "results.txt"
  deploy:
    docker:
      - image: alpine
    steps:
      - run:
          name: Install Curl
          command: apk add --no-cache curl
      - run:
          name: Trigger Regeneration
          command: curl https://www.redbrick.dcu.ie/api/regenerate?token=$KEY

workflows:
  version: 2
  build-test-and-deploy:
    jobs:
      - build
      - test:
          requires:
            - build
      - deploy:
          requires:
            - build
          filters:
            branches:
              only:
                - master