
* Update typos in passwordless setup guide Some key words used in the setup are incorrect and caused confusion for me trying to setup passwordless flow. User should pick Authentication from the "Designation" drop down when creating a flow. Then the stage created should be "Authenticator Validation Stage", not Authentication. Signed-off-by: adrsham <7330099+adrsham@users.noreply.github.com> * ci: fix docker push Signed-off-by: Jens Langhammer <jens@goauthentik.io> * cache only when pushing Signed-off-by: Jens Langhammer <jens@goauthentik.io> * only attest when pushing image Signed-off-by: Jens Langhammer <jens@goauthentik.io> --------- Signed-off-by: adrsham <7330099+adrsham@users.noreply.github.com> Signed-off-by: Jens Langhammer <jens@goauthentik.io> Co-authored-by: Jens Langhammer <jens@goauthentik.io>
66 lines
2.3 KiB
Python
66 lines
2.3 KiB
Python
"""Helper script to get the actual branch name, docker safe"""
|
|
|
|
import configparser
|
|
import os
|
|
from time import time
|
|
|
|
parser = configparser.ConfigParser()
|
|
parser.read(".bumpversion.cfg")
|
|
|
|
should_build = str(len(os.environ.get("DOCKER_USERNAME", "")) > 0).lower()
|
|
|
|
branch_name = os.environ["GITHUB_REF"]
|
|
if os.environ.get("GITHUB_HEAD_REF", "") != "":
|
|
branch_name = os.environ["GITHUB_HEAD_REF"]
|
|
safe_branch_name = branch_name.replace("refs/heads/", "").replace("/", "-").replace("'", "-")
|
|
|
|
image_names = os.getenv("IMAGE_NAME").split(",")
|
|
image_arch = os.getenv("IMAGE_ARCH") or None
|
|
|
|
is_pull_request = bool(os.getenv("PR_HEAD_SHA"))
|
|
is_release = "dev" not in image_names[0]
|
|
|
|
sha = os.environ["GITHUB_SHA"] if not is_pull_request else os.getenv("PR_HEAD_SHA")
|
|
|
|
# 2042.1.0 or 2042.1.0-rc1
|
|
version = parser.get("bumpversion", "current_version")
|
|
# 2042.1
|
|
version_family = ".".join(version.split("-", 1)[0].split(".")[:-1])
|
|
prerelease = "-" in version
|
|
|
|
image_tags = []
|
|
if is_release:
|
|
for name in image_names:
|
|
image_tags += [
|
|
f"{name}:{version}",
|
|
]
|
|
if not prerelease:
|
|
image_tags += [
|
|
f"{name}:latest",
|
|
f"{name}:{version_family}",
|
|
]
|
|
else:
|
|
suffix = ""
|
|
if image_arch and image_arch != "amd64":
|
|
suffix = f"-{image_arch}"
|
|
for name in image_names:
|
|
image_tags += [
|
|
f"{name}:gh-{sha}{suffix}", # Used for ArgoCD and PR comments
|
|
f"{name}:gh-{safe_branch_name}{suffix}", # For convenience
|
|
f"{name}:gh-{safe_branch_name}-{int(time())}-{sha[:7]}{suffix}", # Use by FluxCD
|
|
]
|
|
|
|
image_main_tag = image_tags[0].split(":")[-1]
|
|
image_tags_rendered = ",".join(image_tags)
|
|
image_names_rendered = ",".join(set(name.split(":")[0] for name in image_tags))
|
|
|
|
with open(os.environ["GITHUB_OUTPUT"], "a+", encoding="utf-8") as _output:
|
|
print(f"shouldBuild={should_build}", file=_output)
|
|
print(f"sha={sha}", file=_output)
|
|
print(f"version={version}", file=_output)
|
|
print(f"prerelease={prerelease}", file=_output)
|
|
print(f"imageTags={image_tags_rendered}", file=_output)
|
|
print(f"imageNames={image_names_rendered}", file=_output)
|
|
print(f"imageMainTag={image_main_tag}", file=_output)
|
|
print(f"imageMainName={image_tags[0]}", file=_output)
|