From 173ecc6bf5196a095d68e0072ee8712b1ebae61e Mon Sep 17 00:00:00 2001 From: Valentin Seitz Date: Wed, 2 Aug 2023 18:48:52 +0200 Subject: [PATCH 1/5] Let the games begin :) --- .github/workflows/build-docker.yml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index 0e05525c..4afafa70 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -5,6 +5,7 @@ on: push: branches: - develop + - master jobs: build-and-release-docker-image: @@ -26,11 +27,21 @@ jobs: with: username: ${{ env.docker_username }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Build and push Dockerfile + - name: Build and push latest Dockerfile uses: docker/build-push-action@v2 + if: ${{ env.branch }} == 'master' with: push: true file: "./tools/releasing/packaging/docker/Dockerfile" - tags: ${{ env.docker_username }}/fenics-adapter:${{ env.branch }},${{ env.docker_username }}/fenics-adapter:latest + tags: ${{ env.docker_username }}/fenics-adapter:latest + build-args: | + branch=${{ env.branch }} + - name: Build and push develop Dockerfile + uses: docker/build-push-action@v2 + if: ${{ env.branch }} != 'master' + with: + push: true + file: "./tools/releasing/packaging/docker/Dockerfile" + tags: ${{ env.docker_username }}/fenics-adapter:${{ env.branch }} build-args: | branch=${{ env.branch }} From eebc03e0381a7a78a881ca0055d1157c872a6e96 Mon Sep 17 00:00:00 2001 From: Valentin Seitz Date: Wed, 2 Aug 2023 19:20:09 +0200 Subject: [PATCH 2/5] should still fail? --- .github/workflows/build-docker.yml | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index 4afafa70..8833ba4e 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -1,7 +1,14 @@ name: Update docker image on: - workflow_dispatch: # Trigger by hand from the UI + workflow_dispatch: # Trigger by hand from the UI + inputs: + branch: + type: choice + description: branch to build the container from + options: + - develop + - master push: branches: - develop @@ -14,10 +21,14 @@ jobs: env: docker_username: precice steps: - - name: Get branch name + - name: Set branch name for manual triggering if: github.event_name != 'pull_request' shell: bash - run: echo "branch=$(echo ${GITHUB_REF#refs/heads/} | tr / -)" >> $GITHUB_ENV + run: echo "branch=${{ inputs.branch }}" >> $GITHUB_ENV + - name: Set branch name for manual triggering + if: github.event_name != 'pull_request' + shell: bash + run: echo "branch=${{ github.ref_name }}" >> $GITHUB_ENV - name: Checkout Repository uses: actions/checkout@v2 - name: Set up Docker Buildx From 817a4ecddd4001c57276f0e1225dc5eec1e94cd7 Mon Sep 17 00:00:00 2001 From: Valentin Seitz Date: Wed, 2 Aug 2023 19:24:07 +0200 Subject: [PATCH 3/5] lets try again with a bit more logic --- .github/workflows/build-docker.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index 8833ba4e..0fa77173 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -22,11 +22,11 @@ jobs: docker_username: precice steps: - name: Set branch name for manual triggering - if: github.event_name != 'pull_request' + if: github.event_name == 'workflow_dispatch' shell: bash run: echo "branch=${{ inputs.branch }}" >> $GITHUB_ENV - - name: Set branch name for manual triggering - if: github.event_name != 'pull_request' + - name: Set branch name for on pull triggering + if: github.event_name != 'pull_request' && github.event_name != 'workflow_dispatch' shell: bash run: echo "branch=${{ github.ref_name }}" >> $GITHUB_ENV - name: Checkout Repository From 375dcde43f9d1cda80919b2d001ab451970c33f0 Mon Sep 17 00:00:00 2001 From: Valentin Seitz Date: Wed, 2 Aug 2023 19:32:20 +0200 Subject: [PATCH 4/5] seperate dockerfile concerns in pythonbinding_ref and adapter ref --- .github/workflows/build-docker.yml | 18 ++++++++++++------ tools/releasing/packaging/docker/Dockerfile | 8 ++++---- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index 0fa77173..8825a950 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -24,11 +24,15 @@ jobs: - name: Set branch name for manual triggering if: github.event_name == 'workflow_dispatch' shell: bash - run: echo "branch=${{ inputs.branch }}" >> $GITHUB_ENV + run: | + echo "ADAPTER_REF=${{ inputs.branch }}" >> $GITHUB_ENV + echo "PYTHON_REF=latest" >> $GITHUB_ENV - name: Set branch name for on pull triggering if: github.event_name != 'pull_request' && github.event_name != 'workflow_dispatch' shell: bash - run: echo "branch=${{ github.ref_name }}" >> $GITHUB_ENV + run: | + echo "ADAPTER_REF=${{ github.ref_name }}" >> $GITHUB_ENV + echo "PYTHON_REF=develop" >> $GITHUB_ENV - name: Checkout Repository uses: actions/checkout@v2 - name: Set up Docker Buildx @@ -40,19 +44,21 @@ jobs: password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Build and push latest Dockerfile uses: docker/build-push-action@v2 - if: ${{ env.branch }} == 'master' + if: ${{ env.ADAPTER_REF }} == 'master' with: push: true file: "./tools/releasing/packaging/docker/Dockerfile" tags: ${{ env.docker_username }}/fenics-adapter:latest build-args: | - branch=${{ env.branch }} + FENICS_ADAPTER_REF=${{ env.ADAPTER_REF }} + PYTHON_BINDINGS_REF=${{ env.PYTHON_REF }} - name: Build and push develop Dockerfile uses: docker/build-push-action@v2 - if: ${{ env.branch }} != 'master' + if: ${{ env.ADAPTER_REF }} != 'master' with: push: true file: "./tools/releasing/packaging/docker/Dockerfile" tags: ${{ env.docker_username }}/fenics-adapter:${{ env.branch }} build-args: | - branch=${{ env.branch }} + FENICS_ADAPTER_REF=${{ env.ADAPTER_REF }} + PYTHON_BINDINGS_REF=${{ env.PYTHON_REF }} diff --git a/tools/releasing/packaging/docker/Dockerfile b/tools/releasing/packaging/docker/Dockerfile index 810c6c69..642a22e5 100644 --- a/tools/releasing/packaging/docker/Dockerfile +++ b/tools/releasing/packaging/docker/Dockerfile @@ -1,6 +1,6 @@ # Dockerfile to build a ubuntu image containing the installed Debian package of a release -ARG branch=develop -ARG from=precice/python-bindings:${branch} +ARG PYTHON_BINDINGS_REF=develop +ARG from=precice/python-bindings:${PYTHON_BINDINGS_REF} FROM $from USER root @@ -17,7 +17,7 @@ RUN python3 -m pip install --user --upgrade pip # Rebuild image if force_rebuild after that command ARG CACHEBUST -ARG branch=develop +ARG FENICS_ADAPTER_REF=develop # Building fenics-adapter -RUN python3 -m pip install --user git+https://github.com/precice/fenics-adapter.git@$branch +RUN python3 -m pip install --user git+https://github.com/precice/fenics-adapter.git@$FENICS_ADAPTER_REF From 328847a571365ee033dffe88c7e56a929a805920 Mon Sep 17 00:00:00 2001 From: Valentin Seitz Date: Wed, 2 Aug 2023 20:13:00 +0200 Subject: [PATCH 5/5] adopt to pythonbindings --- .github/workflows/build-docker.yml | 33 +++++++++++++++--------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index 8825a950..6f229cf2 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -25,14 +25,24 @@ jobs: if: github.event_name == 'workflow_dispatch' shell: bash run: | - echo "ADAPTER_REF=${{ inputs.branch }}" >> $GITHUB_ENV - echo "PYTHON_REF=latest" >> $GITHUB_ENV + echo "ADAPTER_REF=${{ inputs.branch }}" >> $GITHUB_ENV - name: Set branch name for on pull triggering if: github.event_name != 'pull_request' && github.event_name != 'workflow_dispatch' shell: bash run: | echo "ADAPTER_REF=${{ github.ref_name }}" >> $GITHUB_ENV - echo "PYTHON_REF=develop" >> $GITHUB_ENV + - name: Set PYTHON_BINDINGS_REF and the TAG depending on branch + shell: bash + run: | + if [[ '${{ env.ADAPTER_REF }}' == 'master' ]]; then + echo "PYTHON_BINDINGS_REF=latest" >> "$GITHUB_ENV" + echo "TAG=latest" >> "$GITHUB_ENV" + echo "Building TAG: latest" + else + echo "PYTHON_BINDINGS_REF=${{ env.ADAPTER_REF }}" >> "$GITHUB_ENV" + echo "TAG=${{ env.ADAPTER_REF }}" >> "$GITHUB_ENV" + echo "Building TAG: ${{ env.ADAPTER_REF }}" + fi - name: Checkout Repository uses: actions/checkout@v2 - name: Set up Docker Buildx @@ -42,23 +52,12 @@ jobs: with: username: ${{ env.docker_username }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Build and push latest Dockerfile - uses: docker/build-push-action@v2 - if: ${{ env.ADAPTER_REF }} == 'master' - with: - push: true - file: "./tools/releasing/packaging/docker/Dockerfile" - tags: ${{ env.docker_username }}/fenics-adapter:latest - build-args: | - FENICS_ADAPTER_REF=${{ env.ADAPTER_REF }} - PYTHON_BINDINGS_REF=${{ env.PYTHON_REF }} - - name: Build and push develop Dockerfile + - name: Build and push Dockerfile uses: docker/build-push-action@v2 - if: ${{ env.ADAPTER_REF }} != 'master' with: push: true file: "./tools/releasing/packaging/docker/Dockerfile" - tags: ${{ env.docker_username }}/fenics-adapter:${{ env.branch }} + tags: ${{ env.docker_username }}/fenics-adapter:${{ env.TAG }} build-args: | FENICS_ADAPTER_REF=${{ env.ADAPTER_REF }} - PYTHON_BINDINGS_REF=${{ env.PYTHON_REF }} + PYTHON_BINDINGS_REF=${{ env.PYTHON_BINDINGS_REF }}