Skip to content

Test Release

Test Release #39

Workflow file for this run

name: Build and push Docker images to Docker Hub
on:
workflow_dispatch:
push:
branches:
- develop
release:
types: [published]
jobs:
build_docker_images:
# This workflow is only of value to PyBaMM and would always be skipped in forks
# if: github.repository_owner == 'pybamm-team'
name: Image (${{ matrix.build-args }})
runs-on: ubuntu-latest
strategy:
matrix:
build-args: ["No solvers", "JAX", "ODES", "IDAKLU", "ALL"]
fail-fast: true
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# - name: Login to Docker Hub
# uses: docker/login-action@v3
# with:
# username: ${{ secrets.DOCKERHUB_USERNAME }}
# password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Create tags for Docker images based on build-time arguments
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' && github.event_name != 'release'
id: tags
run: |
if [ "${{ matrix.build-args }}" = "No solvers" ]; then
echo "tag=latest" >> "$GITHUB_OUTPUT"
elif [ "${{ matrix.build-args }}" = "JAX" ]; then
echo "tag=jax" >> "$GITHUB_OUTPUT"
elif [ "${{ matrix.build-args }}" = "ODES" ]; then
echo "tag=odes" >> "$GITHUB_OUTPUT"
elif [ "${{ matrix.build-args }}" = "IDAKLU" ]; then
echo "tag=idaklu" >> "$GITHUB_OUTPUT"
elif [ "${{ matrix.build-args }}" = "ALL" ]; then
echo "tag=all" >> "$GITHUB_OUTPUT"
fi
- name: Create tags for Docker images based on build-time arguments (release)
if: github.event_name == 'release' && github.event.action == 'published'
id: tags-release
run: |
if [ "${{ matrix.build-args }}" = "No solvers" ]; then
echo "tag=${{ github.event.release.name }}-latest" >> "$GITHUB_OUTPUT"
elif [ "${{ matrix.build-args }}" = "JAX" ]; then
echo "tag=${{ github.event.release.name }}-jax" >> "$GITHUB_OUTPUT"
elif [ "${{ matrix.build-args }}" = "ODES" ]; then
echo "tag=${{ github.event.release.name }}-odes" >> "$GITHUB_OUTPUT"
elif [ "${{ matrix.build-args }}" = "IDAKLU" ]; then
echo "tag=${{ github.event.release.name }}-idaklu" >> "$GITHUB_OUTPUT"
elif [ "${{ matrix.build-args }}" = "ALL" ]; then
echo "tag=${{ github.event.release.name }}-all" >> "$GITHUB_OUTPUT"
fi
- name: Build and push Docker image to Docker Hub (${{ matrix.build-args }})
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' && github.event_name != 'release'
uses: docker/build-push-action@v5
with:
context: .
file: scripts/Dockerfile
tags: pybamm/pybamm:${{ steps.tags.outputs.tag }}
push: true
platforms: linux/amd64, linux/arm64
- name: Build and push Docker image to Docker Hub (${{ matrix.build-args}}) (Release)
if: github.event_name == 'release' && github.event.action == 'published'
uses: docker/build-push-action@v5
with:
context: .
file: scripts/Dockerfile
tags: pybamm/pybamm:${{ steps.tags-release.outputs.tag }}
push: false
platforms: linux/amd64, linux/arm64