From 5e5854e256748e694f0e07be7c081cdbe7d31af0 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Fri, 3 Sep 2021 10:57:44 +0200 Subject: [PATCH] ci: fix invalid workflow Signed-off-by: Jens Langhammer --- .github/workflows/ci-main.yml | 6 ++++-- .github/workflows/ci-outpost.yml | 4 ++-- scripts/gh_do_set_branch.py | 3 +++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci-main.yml b/.github/workflows/ci-main.yml index 0237fadb4..1e836eb80 100644 --- a/.github/workflows/ci-main.yml +++ b/.github/workflows/ci-main.yml @@ -225,11 +225,13 @@ jobs: uses: docker/setup-buildx-action@v1 - name: prepare variables id: ev + env: + DOCKER_USERNAME: ${{ secrets.HARBOR_USERNAME }} run: | python ./scripts/gh_do_set_branch.py - name: Login to Container Registry uses: docker/login-action@v1 - if: ${{ secrets.HARBOR_USERNAME != "" }} + if: ${{ steps.ev.outputs.shouldBuild == 'true' }} with: registry: beryju.org username: ${{ secrets.HARBOR_USERNAME }} @@ -237,7 +239,7 @@ jobs: - name: Building Docker Image uses: docker/build-push-action@v2 with: - push: ${{ secrets.HARBOR_USERNAME != "" }} + push: ${{ steps.ev.outputs.shouldBuild == 'true' }} tags: | beryju.org/authentik/server:gh-${{ steps.ev.outputs.branchName }} beryju.org/authentik/server:gh-${{ steps.ev.outputs.branchName }}-${{ steps.ev.outputs.timestamp }} diff --git a/.github/workflows/ci-outpost.yml b/.github/workflows/ci-outpost.yml index e069bd0f0..c5ad35de3 100644 --- a/.github/workflows/ci-outpost.yml +++ b/.github/workflows/ci-outpost.yml @@ -54,7 +54,7 @@ jobs: python ./scripts/gh_do_set_branch.py - name: Login to Container Registry uses: docker/login-action@v1 - if: ${{ secrets.HARBOR_USERNAME != "" }} + if: ${{ steps.ev.outputs.shouldBuild == 'true' }} with: registry: beryju.org username: ${{ secrets.HARBOR_USERNAME }} @@ -62,7 +62,7 @@ jobs: - name: Building Docker Image uses: docker/build-push-action@v2 with: - push: ${{ secrets.HARBOR_USERNAME != "" }} + push: ${{ steps.ev.outputs.shouldBuild == 'true' }} tags: | beryju.org/authentik/outpost-${{ matrix.type }}:gh-${{ steps.ev.outputs.branchName }} beryju.org/authentik/outpost-${{ matrix.type }}:gh-${{ steps.ev.outputs.branchName }}-${{ steps.ev.outputs.timestamp }} diff --git a/scripts/gh_do_set_branch.py b/scripts/gh_do_set_branch.py index 1c473bf24..efb41e67c 100644 --- a/scripts/gh_do_set_branch.py +++ b/scripts/gh_do_set_branch.py @@ -11,6 +11,9 @@ if os.environ.get(env_pr_branch, "") != "": branch_name = os.environ[env_pr_branch] branch_name = branch_name.replace("refs/heads/", "").replace("/", "-") +should_build = str(os.environ.get("DOCKER_USERNAME", "") != "").lower() + print("##[set-output name=branchName]%s" % branch_name) print("##[set-output name=timestamp]%s" % int(time())) print("##[set-output name=sha]%s" % os.environ[sha]) +print("##[set-output name=shouldBuild]%s" % should_build)