From 3cd65731626389e8aff83770322afde490ab7e31 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Thu, 28 Dec 2023 20:10:53 +0530 Subject: [PATCH] #3312 initial setup, configure release tags via name --- .github/workflows/docker.yml | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 23bc69fcf6..20b111dae7 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -36,6 +36,7 @@ jobs: 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 @@ -50,7 +51,24 @@ jobs: 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: . @@ -59,5 +77,12 @@ jobs: push: true platforms: linux/amd64, linux/arm64 - - name: List built image(s) - run: docker images + - 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