From f9a180eb1f6192bb8395a45a110e06c2e54c4302 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Thu, 7 Oct 2021 20:20:59 +0200 Subject: [PATCH] ci: fix gh_env Signed-off-by: Jens Langhammer --- .github/workflows/ci-main.yml | 4 ++-- .github/workflows/ci-outpost.yml | 2 +- scripts/{gh_do_set_branch.py => gh_env.py} | 3 +-- 3 files changed, 4 insertions(+), 5 deletions(-) rename scripts/{gh_do_set_branch.py => gh_env.py} (90%) diff --git a/.github/workflows/ci-main.yml b/.github/workflows/ci-main.yml index 58a52eddb..997562752 100644 --- a/.github/workflows/ci-main.yml +++ b/.github/workflows/ci-main.yml @@ -152,7 +152,7 @@ jobs: - name: prepare variables id: ev run: | - python ./scripts/gh_do_set_branch.py + python ./scripts/gh_env.py - name: checkout current code run: | set -x @@ -290,7 +290,7 @@ jobs: env: DOCKER_USERNAME: ${{ secrets.HARBOR_USERNAME }} run: | - python ./scripts/gh_do_set_branch.py + python ./scripts/gh_env.py - name: Login to Container Registry uses: docker/login-action@v1 if: ${{ steps.ev.outputs.shouldBuild == 'true' }} diff --git a/.github/workflows/ci-outpost.yml b/.github/workflows/ci-outpost.yml index eee234924..16b1026c1 100644 --- a/.github/workflows/ci-outpost.yml +++ b/.github/workflows/ci-outpost.yml @@ -48,7 +48,7 @@ jobs: env: DOCKER_USERNAME: ${{ secrets.HARBOR_USERNAME }} run: | - python ./scripts/gh_do_set_branch.py + python ./scripts/gh_env.py - name: Login to Container Registry uses: docker/login-action@v1 if: ${{ steps.ev.outputs.shouldBuild == 'true' }} diff --git a/scripts/gh_do_set_branch.py b/scripts/gh_env.py similarity index 90% rename from scripts/gh_do_set_branch.py rename to scripts/gh_env.py index e0adbcaeb..c121c8538 100644 --- a/scripts/gh_do_set_branch.py +++ b/scripts/gh_env.py @@ -9,12 +9,11 @@ sha = "GITHUB_SHA" branch_name = os.environ[default_branch] if os.environ.get(env_pr_branch, "") != "": branch_name = os.environ[env_pr_branch] -branch_name = branch_name.replace("refs/heads/", "") should_build = str(os.environ.get("DOCKER_USERNAME", "") != "").lower() print("##[set-output name=branchName]%s" % branch_name) -print("##[set-output name=branchNameContainer]%s" % branch_name.replace("/", "-")) +print("##[set-output name=branchNameContainer]%s" % branch_name.replace("refs/heads/", "").replace("/", "-")) 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)