fix python error
This commit is contained in:
1 parent
7e4e537aa7
commit
3f7872d23d
1 file changed
+4
-21
@@ -331,42 +331,25 @@ jobs:
|
|||||||
cat << 'EOF' > update_script.py
|
cat << 'EOF' > update_script.py
|
||||||
import os, re
|
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)
|
|
||||||
|
|
||||||
# Falls keine spezifischen gefunden wurden, Fallback auf die üblichen
|
|
||||||
if not env_keys:
|
|
||||||
env_keys = [
|
env_keys = [
|
||||||
"SAMBA_REALM", "SAMBA_DOMAIN", "SAMBA_HOSTNAME",
|
"SAMBA_REALM", "SAMBA_DOMAIN", "SAMBA_HOSTNAME",
|
||||||
"SAMBA_FQDN", "SAMBA_IP", "SAMBA_NETWORK",
|
"SAMBA_FQDN", "SAMBA_IP", "SAMBA_NETWORK",
|
||||||
"DNS_FORWARDER", "SAMBA_ADMIN_PASSWORD"
|
"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 = []
|
env_block_lines = []
|
||||||
for key in env_keys:
|
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)
|
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"
|
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:
|
with open(template_name, "r", encoding="utf-8") as f:
|
||||||
content = f.read()
|
content = f.read()
|
||||||
|
|
||||||
# Ersetzungen durchführen
|
|
||||||
content = content.replace("__REPO_NAME__", "samba-ad-dc")
|
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("__FULL_URL__", "git.pi-farm.de/pi-farm/samba-ad-dc")
|
||||||
content = content.replace("__BUILD_TAG__", os.environ.get("FINAL_TAG", "trixie"))
|
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:
|
with open("docker-compose.yml", "w", encoding="utf-8") as f:
|
||||||
f.write(content)
|
f.write(content)
|
||||||
print("docker-compose.yml erfolgreich mit Platzhaltern generiert!")
|
print("docker-compose.yml erfolgreich generiert!")
|
||||||
EOF
|
EOF
|
||||||
python3 update_script.py
|
python3 update_script.py
|
||||||
rm -f update_script.py
|
rm -f update_script.py
|
||||||
|
|||||||
Reference in new issue
Block a user