You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
packer/.github/workflows/website-docker-publish.yml

34 lines
1.2 KiB

name: "Website Docker Publish"
on:
push:
# Sequence of patterns matched against refs/heads
branches:
# Push events on master branch
- 'master'
jobs:
website-docker-image:
runs-on: ubuntu-latest
name: Build Docker Image if Necessary
env:
DOCKER_USER: ${{ secrets.WEBSITE_DOCKER_USER }}
DOCKER_TOKEN: ${{ secrets.WEBSITE_DOCKER_TOKEN }}
steps:
- uses: actions/checkout@v2
- uses: docker/login-action@v1
with:
username: ${{ env.DOCKER_USER }}
password: ${{ env.DOCKER_TOKEN }}
- run: |
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/packer-website/tags/$IMAGE_TAG -fsL > /dev/null; then
echo "Dependencies have not changed, not building a new website docker image."
else
cd website/
docker build -t hashicorp/packer-website:$IMAGE_TAG .
docker tag hashicorp/packer-website:$IMAGE_TAG hashicorp/packer-website:latest
docker push hashicorp/packer-website
fi