open-nomad/.circleci/config/jobs/website-docker-image.yml

23 lines
929 B
YAML
Raw Normal View History

2020-02-06 23:58:07 +00:00
docker:
- image: circleci/buildpack-deps
shell: /usr/bin/env bash -euo pipefail -c
steps:
- checkout
- setup_remote_docker
- run:
name: Diff package-lock.json
command: |
echo 'export PACKAGE_LOCK_CHANGED=$(git diff --name-only $(git log --pretty=format:'%h' -n1 HEAD~1)...HEAD | grep -c website/package-lock.json)' >> $BASH_ENV
- run:
name: Build Docker Image if Necessary
command: |
if [ "$CIRCLE_BRANCH" = "master" ] && [ $PACKAGE_LOCK_CHANGED -gt 0 ]; then
cd website/
docker build -t hashicorp/nomad-website:$CIRCLE_SHA1 .
docker tag hashicorp/nomad-website:$CIRCLE_SHA1 hashicorp/nomad-website:latest
docker login -u $DOCKER_USER -p $DOCKER_PASS
docker push hashicorp/nomad-website
else
echo "Not building a new website docker image - branch is not master and/or dependencies have not changed."
fi