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