Skip to content

Release (#1057)

Release (#1057) #107

name: Building and publishing container
on:
push:
branches:
- master
tags:
- "v*.*.*"
workflow_dispatch:
jobs:
build_and_publish:
runs-on: ubuntu-latest
steps:
- name: Prepare
id: prep
run: |
DOCKER_IMAGE=openwpm/openwpm
TAGS="${DOCKER_IMAGE}:${GITHUB_SHA}"
# If it's a tagged build it should get published as such
if [[ $GITHUB_REF == refs/tags/v* ]]; then
VERSION=${GITHUB_REF#refs/tags/v}
TAGS="$TAGS,${DOCKER_IMAGE}:$VERSION"
fi
# If it is on master it should get tagged as latest
if [[ $GITHUB_REF == refs/heads/master ]]; then
TAGS="$TAGS,${DOCKER_IMAGE}:latest"
fi
echo ::set-output name=tags::${TAGS}
- name: Checkout
uses: actions/checkout@v3
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Log into Dockerhub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USER_NAME }}
password: ${{ secrets.DOCKERHUB_USER_PASSWORD }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v3
with:
context: ./
file: ./Dockerfile
builder: ${{ steps.buildx.outputs.name }}
push: true
tags: ${{ steps.prep.outputs.tags }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}