Build and publish container to Docker Hub #72
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow builds and pushes the docker image using docker's v2 action | |
# which requires explicitly setting up buildx and logging in | |
name: Build and publish container to Docker Hub | |
on: | |
push: | |
tags: ['^v\d+\.\d+\.\d+$'] # Match tags that resemble a version, but exclude minior releases. For example, v0.1.1-beta would not get included | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
env: | |
DOCKER_ORG: sagebionetworks | |
DOCKER_REPO: schematic | |
steps: | |
- | |
name: Checkout | |
uses: actions/checkout@v3 | |
- | |
name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- | |
name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- | |
name: Login to DockerHub | |
uses: docker/login-action@v2 | |
with: | |
username: schematicbot | |
password: ${{ secrets.DOCKER_HUB_TOKEN }} | |
- | |
name: Compute short commit SHA ID | |
id: vars | |
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" | |
- | |
name: Build and push (tagged release) | |
uses: docker/build-push-action@v3 | |
if: ${{ github.event_name == 'push' }} | |
with: | |
platforms: linux/amd64,linux/arm64 | |
context: . | |
push: true | |
tags: | | |
${{ env.DOCKER_ORG }}/${{ env.DOCKER_REPO }}:latest | |
${{ env.DOCKER_ORG }}/${{ env.DOCKER_REPO }}:${{ github.ref_name }} | |
${{ env.DOCKER_ORG }}/${{ env.DOCKER_REPO }}:commit-${{ steps.vars.outputs.sha_short }} | |
- | |
name: Build and push (manual release) | |
uses: docker/build-push-action@v3 | |
if: ${{ github.event_name == 'workflow_dispatch' }} | |
with: | |
platforms: linux/amd64,linux/arm64 | |
context: . | |
push: true | |
tags: | | |
${{ env.DOCKER_ORG }}/${{ env.DOCKER_REPO }}:commit-${{ steps.vars.outputs.sha_short }} |