version: 2.1 orbs: slack: circleci/slack@3.4.2 readmyhub: gofunky/readmyhub@1.2.2 circle-compare-url: iynere/compare-url@1.2.0 executors: docker-publisher: environment: IMAGE_NAME: awscyberrange/commandcenter CIRCLE_COMPARE_URL: << pipeline.project.git_url >>/compare/<< pipeline.git.base_revision >>..<> docker: - image: circleci/buildpack-deps:stretch jobs: build: executor: docker-publisher steps: - slack/notify: channel: cicd color: '#42e2f4' message: A $CIRCLE_JOB job has started with the latest to master\n\n Compare URL -> $CIRCLE_COMPARE_URL webhook: '${SLACK_WEBHOOK}' - checkout - setup_remote_docker - run: name: Build Docker image command: | docker build -t $IMAGE_NAME:latest . - run: name: Archive Docker image command: docker save -o image.tar $IMAGE_NAME - persist_to_workspace: root: . paths: - ./image.tar publish-latest: executor: docker-publisher steps: - attach_workspace: at: /tmp/workspace - setup_remote_docker - run: name: Load archived Docker image command: docker load -i /tmp/workspace/image.tar - run: name: Publish Docker Image to Docker Hub command: | echo "$DOCKERHUB_PASS" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin docker push $IMAGE_NAME:latest - slack/status: channel: cicd mentions: 'cappetta' webhook: '${SLACK_WEBHOOK}' - circle-compare-url/reconstruct - circle-compare-url/use: step-name: Compare URL Create Step attach-workspace: true - slack/notify: channel: cicd color: '#42e2f4' message: 'A $CIRCLE_JOB job has completed with the following changes \n\n Compare URL -> $CIRCLE_COMPARE_URL [`$(cat CIRCLE_COMPARE_URL.txt)`]' webhook: '${SLACK_WEBHOOK}' - slack/status: channel: cicd mentions: 'cappetta' webhook: '${SLACK_WEBHOOK}' workflows: version: 2 build-master: jobs: - build: filters: branches: only: master - publish-latest: requires: - build filters: branches: only: master