From f9ef57a30a5676b7f54ad7e981194fa58a0da3fd Mon Sep 17 00:00:00 2001 From: Chris Suszynski Date: Wed, 7 Dec 2022 12:54:41 +0100 Subject: [PATCH 1/3] Skip push to registry if secrets are not set --- .github/workflows/multiarch-containerfile-build.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/multiarch-containerfile-build.yaml b/.github/workflows/multiarch-containerfile-build.yaml index 5094b99c5..910bdd254 100644 --- a/.github/workflows/multiarch-containerfile-build.yaml +++ b/.github/workflows/multiarch-containerfile-build.yaml @@ -60,6 +60,7 @@ jobs: - name: Push To ${{ inputs.registry }} id: push-to-quay + if: secrets.QUAY_USER && secrets.QUAY_PASSWORD uses: redhat-actions/push-to-registry@v2 with: image: ${{ steps.build-image.outputs.image }} From eea67f6c3977df863d88b18c759105b7de36d994 Mon Sep 17 00:00:00 2001 From: Chris Suszynski Date: Wed, 7 Dec 2022 12:54:41 +0100 Subject: [PATCH 2/3] Skip push to registry if secrets are not set --- .github/workflows/multiarch-containerfile-build.yaml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/multiarch-containerfile-build.yaml b/.github/workflows/multiarch-containerfile-build.yaml index 910bdd254..a00a7e6ab 100644 --- a/.github/workflows/multiarch-containerfile-build.yaml +++ b/.github/workflows/multiarch-containerfile-build.yaml @@ -30,6 +30,8 @@ jobs: multiarch-build: name: Build images runs-on: ubuntu-22.04 + env: + PRINCIPAL: '${{ secrets.QUAY_USER }}:${{ secrets.QUAY_PASSWORD }}' steps: - uses: actions/checkout@v2 @@ -41,8 +43,12 @@ jobs: echo "Building images from ${GITHUB_REF}@${GITHUB_SHA}" # Ref: https://regex101.com/r/gcxd4h/1 major_minor="$(echo "$ref" | sed -E 's/^.*?v?([[:digit:]]+)\.([[:digit:]]+).*/\1.\2/')" - echo "container_version=v${major_minor}" >> $GITHUB_OUTPUT - echo "Container version: v${major_minor}" + container_version="${GITHUB_SHA}" + if [[ "$major_minor" != "$ref" ]]; then + container_version="v${major_minor}" + fi + echo "container_version=${container_version}" >> $GITHUB_OUTPUT + echo "Container version: ${container_version}" - name: Install qemu dependency run: | @@ -60,7 +66,7 @@ jobs: - name: Push To ${{ inputs.registry }} id: push-to-quay - if: secrets.QUAY_USER && secrets.QUAY_PASSWORD + if: env.PRINCIPAL != ':' uses: redhat-actions/push-to-registry@v2 with: image: ${{ steps.build-image.outputs.image }} From bad2647e7c6e33775c3f5ecc174729bd6809f1e6 Mon Sep 17 00:00:00 2001 From: Chris Suszynski Date: Thu, 8 Dec 2022 13:15:58 +0100 Subject: [PATCH 3/3] Push to registry only for post-submit --- .github/workflows/multiarch-containerfile-build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/multiarch-containerfile-build.yaml b/.github/workflows/multiarch-containerfile-build.yaml index a00a7e6ab..23abc74e0 100644 --- a/.github/workflows/multiarch-containerfile-build.yaml +++ b/.github/workflows/multiarch-containerfile-build.yaml @@ -66,7 +66,7 @@ jobs: - name: Push To ${{ inputs.registry }} id: push-to-quay - if: env.PRINCIPAL != ':' + if: github.event_name == 'push' && env.PRINCIPAL != ':' uses: redhat-actions/push-to-registry@v2 with: image: ${{ steps.build-image.outputs.image }}