This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
authentik/scripts/gh_do_set_branch.py

21 lines
741 B
Python
Raw Normal View History

"""Helper script to get the actual branch name, docker safe"""
import os
from time import time
2021-08-30 18:21:15 +00:00
env_pr_branch = "GITHUB_HEAD_REF"
default_branch = "GITHUB_REF"
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()
2021-08-30 18:21:15 +00:00
print("##[set-output name=branchName]%s" % branch_name)
print("##[set-output name=branchNameContainer]%s" % branch_name.replace("/", "-"))
2021-08-30 18:21:15 +00:00
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)