Attempt uploading docker image to dockerhub automatically. #13
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
name: Docker | ||
on: [push] | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
# If we are on the master branch, build for all architectures. | ||
# Otherwise, only build on the architecture for which we can | ||
# get a runner (for speed). | ||
strategy: | ||
fail-fast: false | ||
if: ${{ github.ref == "master" }} | ||
matrix: | ||
arch: | ||
- amd64 | ||
- arm64 | ||
if: ${{ github.ref != "master" }} | ||
matrix: | ||
arch: | ||
- amd64 | ||
steps: | ||
- name: Prepare | ||
run: | | ||
platform=${{ matrix.platform }} | ||
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
- uses: actions/checkout@v3 | ||
- name: Exit if not on master branch | ||
if: github.ref != 'refs/heads/master' | ||
run: exit 1 | ||
- name: Log in to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: kpeeters/cadabra2-jupyter | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
- name: Build Docker image | ||
uses: docker/build-push-action@v4 | ||
with: | ||
platforms: linux/${{ matrix.arch }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
context: . | ||
file: docker/Dockerfile | ||
push: ${{ github.ref == "master" }} | ||
tags: cadabra2-jupyter-${{ matrix.arch }}:latest | ||
outputs: type=docker,dest=cadabra2-jupyter-${{ matrix.arch }}.tar | ||
- name: Upload artifact to github assets | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: cadabra2-jupyter-${{ matrix.arch }} | ||
path: cadabra2-jupyter-${{ matrix.arch }}.tar |