From caf234ef826566462d43eb6941528f97b09f6a7d Mon Sep 17 00:00:00 2001 From: Matthias G <76126743+sirux88@users.noreply.github.com> Date: Tue, 3 Oct 2023 15:15:39 +0200 Subject: [PATCH] Changes to enable workflow dispatch for 'build' github action (#1446) * reenable manual build workflow and minor fixes * enbale sha tagging for worklow_dispatch only --- .github/workflows/docker-containers.yml | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/.github/workflows/docker-containers.yml b/.github/workflows/docker-containers.yml index c5ff1225a5d..67f9187878a 100644 --- a/.github/workflows/docker-containers.yml +++ b/.github/workflows/docker-containers.yml @@ -8,12 +8,18 @@ on: - "v*.*.*" workflow_dispatch: - + inputs: + dockerPush: + description: 'Push image to docker hub?' + required: true + type: boolean + default: false schedule: # * is a special character in YAML so you have to quote this string # Run every day at 5:24 UTC - build 'latest' docker containers - cron: "24 17 * * *" - +env: + DOCKER_PUSH: true jobs: build: runs-on: ubuntu-latest @@ -35,11 +41,15 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + - name: Set DOCKER_PUSH for workflow_dispatch + if: ${{ github.event_name == 'workflow_dispatch' }} + run: echo "DOCKER_PUSH=${{ github.event.inputs.dockerPush }}" >> $GITHUB_ENV + - name: Populate Docker metadata id: meta uses: docker/metadata-action@v5 with: - images: pglombardo/pwpush-${{ matrix.dbType }} + images: ${{ secrets.DOCKER_USERNAME }}/pwpush-${{ matrix.dbType }} flavor: | latest=false tags: | @@ -49,9 +59,11 @@ jobs: type=semver,pattern={{major}}.{{minor}} type=semver,pattern={{major}} type=semver,pattern=latest + type=sha,enable=${{ github.event_name == 'workflow_dispatch' }} - name: Login to DockerHub uses: docker/login-action@v3 + if: ${{env.DOCKER_PUSH == 'true'}} with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} @@ -62,8 +74,8 @@ jobs: file: ./containers/docker/pwpush-${{ matrix.dbType }}/Dockerfile platforms: linux/amd64,linux/arm64 provenance: false - push: true + push: ${{env.DOCKER_PUSH == 'true'}} labels: ${{ steps.meta.outputs.labels }} tags: ${{ steps.meta.outputs.tags }} cache-from: type=registry,ref=${{ secrets.DOCKER_USERNAME }}/pwpush-${{ matrix.dbType }}:buildcache - cache-to: type=registry,ref=${{ secrets.DOCKER_USERNAME }}/pwpush-${{ matrix.dbType }}:buildcache,mode=max + cache-to: type=registry,ref=${{ secrets.DOCKER_USERNAME }}/pwpush-${{ matrix.dbType }}:buildcache,mode=max,ignore-error=${{env.DOCKER_PUSH == 'false'}}