2021-02-28 13:24:16 +00:00
|
|
|
"""Helper script to get the actual branch name, docker safe"""
|
|
|
|
import os
|
2021-05-26 08:37:33 +00:00
|
|
|
from time import time
|
2021-02-28 13:24:16 +00:00
|
|
|
|
2021-08-30 18:21:15 +00:00
|
|
|
env_pr_branch = "GITHUB_HEAD_REF"
|
|
|
|
default_branch = "GITHUB_REF"
|
2021-09-01 14:19:29 +00:00
|
|
|
sha = "GITHUB_SHA"
|
2021-02-28 13:24:16 +00:00
|
|
|
|
|
|
|
branch_name = os.environ[default_branch]
|
2021-09-01 14:19:29 +00:00
|
|
|
if os.environ.get(env_pr_branch, "") != "":
|
|
|
|
branch_name = os.environ[env_pr_branch]
|
2021-02-28 13:24:16 +00:00
|
|
|
|
2021-09-03 08:57:44 +00:00
|
|
|
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)
|
2021-10-07 18:20:59 +00:00
|
|
|
print("##[set-output name=branchNameContainer]%s" % branch_name.replace("refs/heads/", "").replace("/", "-"))
|
2021-08-30 18:21:15 +00:00
|
|
|
print("##[set-output name=timestamp]%s" % int(time()))
|
2021-09-01 14:19:29 +00:00
|
|
|
print("##[set-output name=sha]%s" % os.environ[sha])
|
2021-09-03 08:57:44 +00:00
|
|
|
print("##[set-output name=shouldBuild]%s" % should_build)
|