version: 2
jobs:
  build:
    docker:
      # circleci/ruby:2.4-node-browsers + awscli
      - image: kenmickles/fftf-static-site-builder:0.0.1

    steps:
      - checkout

      - restore_cache:
          keys:
          - v1-dependencies-{{ checksum "package-lock.json" }}

      - run:
          name: Install dependencies
          command: |
            npm install

      - save_cache:
          paths:
          - node_modules
          key: v1-dependencies-{{ checksum "package-lock.json" }}

      - run: 
          name: Build
          command: |
            NODE_ENV=production npm run build
            NODE_ENV=production npm run htmllint

      - deploy:
          name: Deploy to S3
          command: |
            npm run deploy

      - run:
          name: Purge CloudFlare cache
          command: |
            curl -X DELETE "https://api.cloudflare.com/client/v4/zones/${CLOUDFLARE_ZONE}/purge_cache" \
              -H "X-Auth-Email: ${CLOUDFLARE_EMAIL}" \
              -H "X-Auth-Key: ${CLOUDFLARE_SECRET}" \
              -H "Content-Type: application/json" \
              --data '{"purge_everything":true}'

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

version: 2
jobs:
  build:
    docker:
      # circleci/ruby:2.4-node-browsers + awscli
      - image: kenmickles/fftf-static-site-builder:0.0.1

    steps:
      - checkout

      - restore_cache:
          keys:
          - v1-dependencies-{{ checksum "package-lock.json" }}

      - run:
          name: Install dependencies
          command: |
            npm install

      - save_cache:
          paths:
          - node_modules
          key: v1-dependencies-{{ checksum "package-lock.json" }}

      - run: 
          name: Build
          command: |
            NODE_ENV=production npm run build
            NODE_ENV=production npm run htmllint
            CACHE_BUST=`git rev-parse HEAD` && sed -i "s/CACHE_BUST/$$CACHE_BUST/g" index.html breaktheinternet/index.html breaktheinternet/twitter.html scoreboard/index.html

      - deploy:
          name: Deploy to S3
          command: |
            npm run deploy

      - run:
          name: Purge CloudFlare cache
          command: |
            curl -X DELETE "https://api.cloudflare.com/client/v4/zones/${CLOUDFLARE_ZONE}/purge_cache" \
              -H "X-Auth-Email: ${CLOUDFLARE_EMAIL}" \
              -H "X-Auth-Key: ${CLOUDFLARE_SECRET}" \
              -H "Content-Type: application/json" \
              --data '{"purge_everything":true}'

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

Add cache bust back into Circle CI build step
Add cache bust back into Circle CI build step
