62 lines
2.1 KiB
YAML
62 lines
2.1 KiB
YAML
name: 'Prepare docker environment variables'
|
|
description: 'Prepare docker environment variables'
|
|
|
|
outputs:
|
|
shouldBuild:
|
|
description: "Whether to build image or not"
|
|
value: ${{ steps.ev.outputs.shouldBuild }}
|
|
branchName:
|
|
description: "Branch name"
|
|
value: ${{ steps.ev.outputs.branchName }}
|
|
branchNameContainer:
|
|
description: "Branch name (for containers)"
|
|
value: ${{ steps.ev.outputs.branchNameContainer }}
|
|
timestamp:
|
|
description: "Timestamp"
|
|
value: ${{ steps.ev.outputs.timestamp }}
|
|
sha:
|
|
description: "sha"
|
|
value: ${{ steps.ev.outputs.sha }}
|
|
version:
|
|
description: "version"
|
|
value: ${{ steps.ev.outputs.version }}
|
|
versionFamily:
|
|
description: "versionFamily"
|
|
value: ${{ steps.ev.outputs.versionFamily }}
|
|
|
|
runs:
|
|
using: "composite"
|
|
steps:
|
|
- name: Generate config
|
|
id: ev
|
|
shell: python
|
|
run: |
|
|
"""Helper script to get the actual branch name, docker safe"""
|
|
import configparser
|
|
import os
|
|
from time import time
|
|
|
|
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]
|
|
|
|
should_build = str(os.environ.get("DOCKER_USERNAME", "") != "").lower()
|
|
parser = configparser.ConfigParser()
|
|
parser.read(".bumpversion.cfg")
|
|
version = parser.get("bumpversion", "current_version")
|
|
version_family = ".".join(version.split(".")[:-1])
|
|
safe_branch_name = branch_name.replace("refs/heads/", "").replace("/", "-")
|
|
|
|
with open(os.environ["GITHUB_OUTPUT"], "w+", encoding="utf-8") as _output:
|
|
_output.write("branchName=%s" % branch_name)
|
|
_output.write("branchNameContainer=%s" % safe_branch_name)
|
|
_output.write("timestamp=%s" % int(time()))
|
|
_output.write("sha=%s" % os.environ[sha])
|
|
_output.write("shouldBuild=%s" % should_build)
|
|
_output.write("version=%s" % version)
|
|
_output.write("versionFamily=%s" % version_family)
|