diff --git a/.gitea/workflows/build-and-push.yaml b/.gitea/workflows/build-and-push.yaml index d0b4383..1613bb3 100644 --- a/.gitea/workflows/build-and-push.yaml +++ b/.gitea/workflows/build-and-push.yaml @@ -331,42 +331,25 @@ jobs: cat << 'EOF' > update_script.py import os, re - # 1. Wir lesen die Schlüsselnamen (Keys) aus der buildargs.env aus, - # damit wir wissen, welche Variablen als Platzhalter eingefügt werden sollen. - env_keys = [] - if os.path.exists("buildargs.env"): - with open("buildargs.env", "r", encoding="utf-8") as f: - for line in f: - line = line.strip() - # Ignoriere Kommentare und leere Zeilen - if line and not line.startswith("#") and "=" in line: - key = line.split("=")[0].strip() - # Wir wollen nur die SAMBA_-Variablen oder alle BUILD_-Variablen ausschließen - if key.startswith("SAMBA_") or key.startswith("DNS_"): - env_keys.append(key) + env_keys = [ + "SAMBA_REALM", "SAMBA_DOMAIN", "SAMBA_HOSTNAME", + "SAMBA_FQDN", "SAMBA_IP", "SAMBA_NETWORK", + "DNS_FORWARDER", "SAMBA_ADMIN_PASSWORD" + ] - # Falls keine spezifischen gefunden wurden, Fallback auf die üblichen - if not env_keys: - env_keys = [ - "SAMBA_REALM", "SAMBA_DOMAIN", "SAMBA_HOSTNAME", - "SAMBA_FQDN", "SAMBA_IP", "SAMBA_NETWORK", - "DNS_FORWARDER", "SAMBA_ADMIN_PASSWORD" - ] - - # 2. Erzeuge den Env-Block mit ${VARIABLE_NAME} Syntax (doppelte geschweifte Klammern für F-String Maskierung) + # Env-Block ohne F-String-Klammern zusammenbauen, damit Gitea nicht stolpert env_block_lines = [] for key in env_keys: - env_block_lines.append(f" {key}: ${{{key}}}") + line = " " + key + ": ${" + key + "}" + env_block_lines.append(line) env_block_str = "\n".join(env_block_lines) - # 3. Template einlesen und Platzhalter ersetzen template_name = ".gitea/docker-compose.template" if os.path.exists(".gitea/docker-compose.template") else "docker-compose.template" with open(template_name, "r", encoding="utf-8") as f: content = f.read() - # Ersetzungen durchführen content = content.replace("__REPO_NAME__", "samba-ad-dc") content = content.replace("__FULL_URL__", "git.pi-farm.de/pi-farm/samba-ad-dc") content = content.replace("__BUILD_TAG__", os.environ.get("FINAL_TAG", "trixie")) @@ -374,7 +357,7 @@ jobs: with open("docker-compose.yml", "w", encoding="utf-8") as f: f.write(content) - print("docker-compose.yml erfolgreich mit Platzhaltern generiert!") + print("docker-compose.yml erfolgreich generiert!") EOF python3 update_script.py rm -f update_script.py