[website] CircleCI Script Updates (#7145)

* circle-ci script updates 🎉

* trigger deploy as a test

* remove testing items
This commit is contained in:
Jeff Escalante 2020-02-18 13:42:50 -05:00 committed by GitHub
parent 6a1764edb3
commit e35e1652cf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 18 deletions

23
.circleci/config.yml generated
View file

@ -452,18 +452,19 @@ jobs:
- setup_remote_docker
- run:
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
name: Diff package-lock.json
- run:
command: |
if [ "$CIRCLE_BRANCH" = "master" ] && [ $PACKAGE_LOCK_CHANGED -gt 0 ]; then
# There is an edge case that would cause an issue here - if dependencies are updated to an exact copy
# of a previous version, for example if packge-lock.json is reverted, we need to manually push the new
# image to the "latest" tag
IMAGE_TAG=$(cat website/Dockerfile website/package-lock.json | sha256sum | awk '{print $1;}')
echo "Using $IMAGE_TAG"
if ! curl https://hub.docker.com/v2/repositories/hashicorp/nomad-website/tags/$IMAGE_TAG -fsL > /dev/null; 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 build -t hashicorp/nomad-website:$IMAGE_TAG .
docker tag hashicorp/nomad-website:$IMAGE_TAG hashicorp/nomad-website:latest
docker login -u $WEBSITE_DOCKER_USER -p $WEBSITE_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."
echo "Dependencies have not changed, not building a new website docker image."
fi
name: Build Docker Image if Necessary
test-other:
@ -907,5 +908,9 @@ workflows:
website:
jobs:
- website-docker-image:
filters:
branches:
only:
- master
context: static-sites
version: 2

View file

@ -4,19 +4,20 @@ 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
# There is an edge case that would cause an issue here - if dependencies are updated to an exact copy
# of a previous version, for example if packge-lock.json is reverted, we need to manually push the new
# image to the "latest" tag
IMAGE_TAG=$(cat website/Dockerfile website/package-lock.json | sha256sum | awk '{print $1;}')
echo "Using $IMAGE_TAG"
if ! curl https://hub.docker.com/v2/repositories/hashicorp/nomad-website/tags/$IMAGE_TAG -fsL > /dev/null; 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 build -t hashicorp/nomad-website:$IMAGE_TAG .
docker tag hashicorp/nomad-website:$IMAGE_TAG hashicorp/nomad-website:latest
docker login -u $WEBSITE_DOCKER_USER -p $WEBSITE_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."
echo "Dependencies have not changed, not building a new website docker image."
fi

View file

@ -1,3 +1,7 @@
jobs:
- website-docker-image:
context: static-sites
filters:
branches:
only:
- master