Skip to content

Commit

Permalink
Restoring Docker build (#871)
Browse files Browse the repository at this point in the history
GitHub Action based on https://github.com/usha-mandya/SimpleWhaleDemo/blob/master/.github/workflows/github_registry.yml

Everything on the master branch gets published as `:latest` and version tags (pattern `vx.y.z`) get published as `:x.y.z`
  • Loading branch information
Stefan Zabka authored Mar 29, 2021
1 parent 3241482 commit 358c8a7
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/build-container.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
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@v2
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v2
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@v2
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 }}

0 comments on commit 358c8a7

Please sign in to comment.