From 7276600c539fc4931651f2ec3a88a86c9640b46f Mon Sep 17 00:00:00 2001 From: "info@pi-farm.de" <6+pi-farm@noreply.git.pi-farm.de> Date: Wed, 7 Oct 2026 15:55:12 +0000 Subject: [PATCH] .gitea/workflows/build-and-push.yaml aktualisiert --- .gitea/workflows/build-and-push.yaml | 79 +++++++++++++++------------- 1 file changed, 43 insertions(+), 36 deletions(-) diff --git a/.gitea/workflows/build-and-push.yaml b/.gitea/workflows/build-and-push.yaml index 90919db..c82c376 100644 --- a/.gitea/workflows/build-and-push.yaml +++ b/.gitea/workflows/build-and-push.yaml @@ -325,45 +325,52 @@ jobs: (apt-get update && apt-get install -y python3) || (apk add --no-cache python3) || true fi - process_template() { - local template=$1; local output=$2 - [ ! -f "$template" ] && return - cp "$template" "$output" + # Python-Skript sauber als eigene Datei erstellen (vermeidet YAML-Syntaxfehler) + cat << 'EOF' > update_script.py + import os, sys - export REPO_PURE FULL_URL BUILD_TAG BASE_IMAGE ARM_STATUS CURRENT_TIME \ - HISTORY_CONTENT DOCKERHUB_LINK_CONTENT ENV_BLOCK_CONTENT \ - PORTS_BLOCK_CONTENT VOL_BLOCK_CONTENT DESCRIPTION + def process(output_file): + if not os.path.exists(output_file.replace('.md', '.template').replace('.yml', '.template')): + return + + template_name = output_file.replace('.md', '.template').replace('.yml', '.template') + with open(template_name, "r", encoding="utf-8") as f: + content = f.read() - python3 -c ' -import os, sys -output = sys.argv[1] -with open(output, "r", encoding="utf-8") as f: - content = f.read() -content = content.replace("__REPO_NAME__", os.environ.get("REPO_PURE", "")) -content = content.replace("__FULL_URL__", os.environ.get("FULL_URL", "")) -content = content.replace("__BUILD_TAG__", os.environ.get("BUILD_TAG", "")) -content = content.replace("__BASE_IMAGE__", os.environ.get("BASE_IMAGE", "")) -content = content.replace("__ARM_STATUS__", os.environ.get("ARM_STATUS", "")) -content = content.replace("__CURRENT_DATE__", os.environ.get("CURRENT_TIME", "")) -content = content.replace("__HISTORY_CONTENT__", os.environ.get("HISTORY_CONTENT", "")) -content = content.replace("__DOCKERHUB_LINK__", os.environ.get("DOCKERHUB_LINK_CONTENT", "")) -content = content.replace("__ENV_BLOCK__", os.environ.get("ENV_BLOCK_CONTENT", "").replace("\\n", "\n")) -content = content.replace("__PORTS_BLOCK__", os.environ.get("PORTS_BLOCK_CONTENT", "").replace("\\n", "\n")) -content = content.replace("__VOL_BLOCK__", os.environ.get("VOL_BLOCK_CONTENT", "").replace("\\n", "\n")) -content = content.replace("__DESCRIPTION__", os.environ.get("DESCRIPTION", "Keine Beschreibung.")) -if "__DOCKER_RUN__" in content and os.path.exists("docker_run_block.txt"): - with open("docker_run_block.txt", "r", encoding="utf-8") as f: - content = content.replace("__DOCKER_RUN__", f.read()) -if "__COMPOSE_BLOCK__" in content and os.path.exists("docker-compose.yml"): - with open("docker-compose.yml", "r", encoding="utf-8") as f: - content = content.replace("__COMPOSE_BLOCK__", f.read()) -with open(output, "w", encoding="utf-8") as f: - f.write(content) -' "$output" - } + content = content.replace("__REPO_NAME__", os.environ.get("REPO_PURE", "")) + content = content.replace("__FULL_URL__", os.environ.get("FULL_URL", "")) + content = content.replace("__BUILD_TAG__", os.environ.get("BUILD_TAG", "")) + content = content.replace("__BASE_IMAGE__", os.environ.get("BASE_IMAGE", "")) + content = content.replace("__ARM_STATUS__", os.environ.get("ARM_STATUS", "")) + content = content.replace("__CURRENT_DATE__", os.environ.get("CURRENT_TIME", "")) + content = content.replace("__HISTORY_CONTENT__", os.environ.get("HISTORY_CONTENT", "")) + content = content.replace("__DOCKERHUB_LINK__", os.environ.get("DOCKERHUB_LINK_CONTENT", "")) + content = content.replace("__ENV_BLOCK__", os.environ.get("ENV_BLOCK_CONTENT", "").replace("\\n", "\n")) + content = content.replace("__PORTS_BLOCK__", os.environ.get("PORTS_BLOCK_CONTENT", "").replace("\\n", "\n")) + content = content.replace("__VOL_BLOCK__", os.environ.get("VOL_BLOCK_CONTENT", "").replace("\\n", "\n")) + content = content.replace("__DESCRIPTION__", os.environ.get("DESCRIPTION", "Keine Beschreibung.")) - process_template "docker-compose.template" "docker-compose.yml" - process_template "README.template" "README.md" + if "__DOCKER_RUN__" in content and os.path.exists("docker_run_block.txt"): + with open("docker_run_block.txt", "r", encoding="utf-8") as f: + content = content.replace("__DOCKER_RUN__", f.read()) + + if "__COMPOSE_BLOCK__" in content and os.path.exists("docker-compose.yml"): + with open("docker-compose.yml", "r", encoding="utf-8") as f: + content = content.replace("__COMPOSE_BLOCK__", f.read()) + + with open(output_file, "w", encoding="utf-8") as f: + f.write(content) + + process("docker-compose.yml") + process("README.md") + EOF + + export REPO_PURE FULL_URL BUILD_TAG BASE_IMAGE ARM_STATUS CURRENT_TIME \ + HISTORY_CONTENT DOCKERHUB_LINK_CONTENT ENV_BLOCK_CONTENT \ + PORTS_BLOCK_CONTENT VOL_BLOCK_CONTENT DESCRIPTION + + python3 update_script.py + rm -f update_script.py echo "FINAL_MSG=$COMMIT_MSG" >> $GITHUB_ENV {