Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build & Push Docker Images on releases #3661

Draft
wants to merge 6 commits into
base: develop
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
149 changes: 88 additions & 61 deletions .github/workflows/docker.yml
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The entire file shows up as changed, possibly due to a difference in line endings schemes?

Original file line number Diff line number Diff line change
@@ -1,61 +1,88 @@
name: Build and push Docker images to Docker Hub

on:
workflow_dispatch:
push:
branches:
- develop

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
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: Build and push Docker image to Docker Hub (${{ matrix.build-args }})
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: List built image(s)
run: docker images
name: Build and push Docker images to Docker Hub

on:
workflow_dispatch:
push:
branches:
- develop
release:
types: [published]

Comment on lines +8 to +9
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
release:
types: [published]
release:
types: [released]

in light of #3661 (comment). The changes from this PR won't be available until 24.5rc0 anyway, so we have time to resolve #3692 and #3666 till then – they should be resolved prior to resuming work on this PR.

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.ref_name }}-latest" >> "$GITHUB_OUTPUT"
elif [ "${{ matrix.build-args }}" = "JAX" ]; then
echo "tag=${{ github.ref_name }}-jax" >> "$GITHUB_OUTPUT"
elif [ "${{ matrix.build-args }}" = "ODES" ]; then
echo "tag=${{ github.ref_name }}-odes" >> "$GITHUB_OUTPUT"
elif [ "${{ matrix.build-args }}" = "IDAKLU" ]; then
echo "tag=${{ github.ref_name }}-idaklu" >> "$GITHUB_OUTPUT"
elif [ "${{ matrix.build-args }}" = "ALL" ]; then
echo "tag=${{ github.ref_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: true
platforms: linux/amd64, linux/arm64
Loading