From fc209687d9937823b59efcc2e2f58c49d23916ff Mon Sep 17 00:00:00 2001 From: Faustin Lammler Date: Thu, 24 Aug 2023 11:43:23 +0200 Subject: [PATCH] Only push to ghcr.io on main forks This should make it possible to build and push images on forks registries. --- .github/workflows/bb_containers.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/bb_containers.yml b/.github/workflows/bb_containers.yml index 0526a458..de578c9e 100644 --- a/.github/workflows/bb_containers.yml +++ b/.github/workflows/bb_containers.yml @@ -259,13 +259,19 @@ jobs: fi - name: Login to ghcr.io uses: docker/login-action@v2 - if: (!contains(matrix.dockerfile, 'rhel')) + # this should make it possible to build images in main forks. + if: > + (!contains(matrix.dockerfile, 'rhel')) && + github.head_ref == 'main' with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Push images to ghcr.io - if: (!contains(matrix.dockerfile, 'rhel')) + # this should make it possible to build images in main forks. + if: > + (!contains(matrix.dockerfile, 'rhel')) && + github.head_ref == 'main' run: | msg="Push docker image to ghcr.io (${{ env.IMG }})" line="${msg//?/=}"