diff --git a/.github/actions/docker-push-variables/push_vars.py b/.github/actions/docker-push-variables/push_vars.py index f4bbabb8f0..15738cd631 100644 --- a/.github/actions/docker-push-variables/push_vars.py +++ b/.github/actions/docker-push-variables/push_vars.py @@ -7,6 +7,8 @@ from time import time parser = configparser.ConfigParser() parser.read(".bumpversion.cfg") +should_build = str(os.environ.get("DOCKER_USERNAME", None) is not None).lower() + branch_name = os.environ["GITHUB_REF"] if os.environ.get("GITHUB_HEAD_REF", "") != "": branch_name = os.environ["GITHUB_HEAD_REF"] @@ -52,6 +54,7 @@ image_main_tag = image_tags[0] image_tags_rendered = ",".join(image_tags) with open(os.environ["GITHUB_OUTPUT"], "a+", encoding="utf-8") as _output: + print("shouldBuild=%s" % should_build, file=_output) print("sha=%s" % sha, file=_output) print("version=%s" % version, file=_output) print("prerelease=%s" % prerelease, file=_output) diff --git a/.github/workflows/ci-main.yml b/.github/workflows/ci-main.yml index 96a235c4e2..8004f989df 100644 --- a/.github/workflows/ci-main.yml +++ b/.github/workflows/ci-main.yml @@ -219,7 +219,6 @@ jobs: # Needed to upload contianer images to ghcr.io packages: write timeout-minutes: 120 - if: "github.repository == 'goauthentik/authentik'" steps: - uses: actions/checkout@v4 with: @@ -235,6 +234,7 @@ jobs: image-name: ghcr.io/goauthentik/dev-server image-arch: ${{ matrix.arch }} - name: Login to Container Registry + if: ${{ steps.ev.outputs.shouldBuild == 'true' }} uses: docker/login-action@v3 with: registry: ghcr.io @@ -250,7 +250,7 @@ jobs: GEOIPUPDATE_ACCOUNT_ID=${{ secrets.GEOIPUPDATE_ACCOUNT_ID }} GEOIPUPDATE_LICENSE_KEY=${{ secrets.GEOIPUPDATE_LICENSE_KEY }} tags: ${{ steps.ev.outputs.imageTags }} - push: true + push: ${{ steps.ev.outputs.shouldBuild == 'true' }} build-args: | GIT_BUILD_HASH=${{ steps.ev.outputs.sha }} cache-from: type=gha diff --git a/.github/workflows/ci-outpost.yml b/.github/workflows/ci-outpost.yml index 2ef9277cbb..15c3451048 100644 --- a/.github/workflows/ci-outpost.yml +++ b/.github/workflows/ci-outpost.yml @@ -71,7 +71,6 @@ jobs: permissions: # Needed to upload contianer images to ghcr.io packages: write - if: "github.repository == 'goauthentik/authentik'" steps: - uses: actions/checkout@v4 with: @@ -86,6 +85,7 @@ jobs: with: image-name: ghcr.io/goauthentik/dev-${{ matrix.type }} - name: Login to Container Registry + if: ${{ steps.ev.outputs.shouldBuild == 'true' }} uses: docker/login-action@v3 with: registry: ghcr.io @@ -98,7 +98,7 @@ jobs: with: tags: ${{ steps.ev.outputs.imageTags }} file: ${{ matrix.type }}.Dockerfile - push: true + push: ${{ steps.ev.outputs.shouldBuild == 'true' }} build-args: | GIT_BUILD_HASH=${{ steps.ev.outputs.sha }} platforms: linux/amd64,linux/arm64