.gitea/workflows/build-and-push.yaml aktualisiert
build-and-push.yaml / release-and-build (push) Successful in 25m5s

This commit is contained in:
pi-farm committed 2026-10-06 15:59:13 +00:00
1 parent 2be18e6fd2
commit a2f1c987f8
1 file changed
+49 -24
+49 -24
View File
@@ -212,8 +212,23 @@ jobs:
EOF EOF
COMMIT_MSG=$(sed 's/\[skip ci\]//g' commit_msg.txt | xargs) COMMIT_MSG=$(sed 's/\[skip ci\]//g' commit_msg.txt | xargs)
wget -q https://git.pi-farm.de/pi-farm/templates/raw/branch/main/README.template -O README.template || echo "Warnung: README Template fehlt" # 1. Authentifizierter Download der Templates via curl (-f bricht bei HTTP-Fehlern ab)
wget -q https://git.pi-farm.de/pi-farm/templates/raw/branch/main/docker-compose.template -O docker-compose.template || echo "Warnung: Compose Template fehlt" TOKEN="${{ secrets.RUNNER_TOKEN }}"
curl -sSLf -H "Authorization: token $TOKEN" \
"https://git.pi-farm.de/pi-farm/templates/raw/branch/main/README.template" \
-o README.template || echo "Warnung: README Template konnte nicht geladen werden"
curl -sSLf -H "Authorization: token $TOKEN" \
"https://git.pi-farm.de/pi-farm/templates/raw/branch/main/docker-compose.template" \
-o docker-compose.template || echo "Warnung: Compose Template konnte nicht geladen werden"
# 2. Sicherheitsprüfung: Falls Gitea trotz -f eine HTML-Login-Seite ausgibt, Datei sofort verwerfen
for t_file in README.template docker-compose.template; do
if [ -f "$t_file" ] && grep -qi "<!DOCTYPE html>" "$t_file"; then
echo "❌ FEHLER: $t_file ist eine HTML-Loginseite! Download verworfen."
rm -f "$t_file"
fi
done
NEW_ROW="| **$BUILD_TAG** | $CURRENT_TIME | $COMMIT_MSG ✅ |" NEW_ROW="| **$BUILD_TAG** | $CURRENT_TIME | $COMMIT_MSG ✅ |"
if [ -f "VERSION.history" ]; then if [ -f "VERSION.history" ]; then
@@ -287,38 +302,48 @@ jobs:
DOCKERHUB_LINK_CONTENT="[![Docker Hub](https://img.shields.io/badge/docker-hub-blue?logo=docker&logoColor=white)](https://hub.docker.com/r/${DH_USER}/${REPO_PURE})" DOCKERHUB_LINK_CONTENT="[![Docker Hub](https://img.shields.io/badge/docker-hub-blue?logo=docker&logoColor=white)](https://hub.docker.com/r/${DH_USER}/${REPO_PURE})"
fi fi
# Template-Verarbeitung via Python (verhindert awk-Abstürze bei Zeilenumbrüchen)
process_template() { process_template() {
local template=$1; local output=$2 local template=$1; local output=$2
[ ! -f "$template" ] && return [ ! -f "$template" ] && return
cp "$template" "$output" cp "$template" "$output"
sed -i "s|__REPO_NAME__|$REPO_PURE|g" "$output" export REPO_PURE FULL_URL BUILD_TAG BASE_IMAGE ARM_STATUS CURRENT_TIME \
sed -i "s|__FULL_URL__|$FULL_URL|g" "$output" HISTORY_CONTENT DOCKERHUB_LINK_CONTENT ENV_BLOCK_CONTENT \
sed -i "s|__BUILD_TAG__|$BUILD_TAG|g" "$output" PORTS_BLOCK_CONTENT VOL_BLOCK_CONTENT DESCRIPTION
sed -i "s|__BASE_IMAGE__|$BASE_IMAGE|g" "$output"
sed -i "s|__ARM_STATUS__|$ARM_STATUS|g" "$output"
sed -i "s|__CURRENT_DATE__|$CURRENT_TIME|g" "$output"
awk -v r="$HISTORY_CONTENT" '{gsub(/__HISTORY_CONTENT__/, r)}1' "$output" > "$output.tmp" && mv "$output.tmp" "$output" python3 -c '
awk -v r="$DOCKERHUB_LINK_CONTENT" '{gsub(/__DOCKERHUB_LINK__/, r)}1' "$output" > "$output.tmp" && mv "$output.tmp" "$output" import os, sys
if grep -q "__DOCKER_RUN__" "$output" && [ -f "docker_run_block.txt" ]; then output = sys.argv[1]
sed -e '/__DOCKER_RUN__/{r docker_run_block.txt' -e 'd;}' "$output" > "$output.tmp" && mv "$output.tmp" "$output"
fi
if grep -q "__COMPOSE_BLOCK__" "$output" && [ -f "docker-compose.yml" ]; then with open(output, "r", encoding="utf-8") as f:
sed -e '/__COMPOSE_BLOCK__/{r docker-compose.yml' -e 'd;}' "$output" > "$output.tmp" && mv "$output.tmp" "$output" content = f.read()
fi
if grep -q "__ENV_BLOCK__" "$output"; then content = content.replace("__REPO_NAME__", os.environ.get("REPO_PURE", ""))
awk -v r="$(echo -e "$ENV_BLOCK_CONTENT")" '{gsub(/__ENV_BLOCK__/, r)}1' "$output" > "$output.tmp" && mv "$output.tmp" "$output" content = content.replace("__FULL_URL__", os.environ.get("FULL_URL", ""))
fi content = content.replace("__BUILD_TAG__", os.environ.get("BUILD_TAG", ""))
awk -v r="$(echo -e "$PORTS_BLOCK_CONTENT")" '{gsub(/__PORTS_BLOCK__/, r)}1' "$output" > "$output.tmp" && mv "$output.tmp" "$output" content = content.replace("__BASE_IMAGE__", os.environ.get("BASE_IMAGE", ""))
awk -v r="$(echo -e "$VOL_BLOCK_CONTENT")" '{gsub(/__VOL_BLOCK__/, r)}1' "$output" > "$output.tmp" && mv "$output.tmp" "$output" 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 grep -q "__DESCRIPTION__" "$output"; then if "__DOCKER_RUN__" in content and os.path.exists("docker_run_block.txt"):
awk -v r="$(echo -e "${DESCRIPTION:-Keine Beschreibung.}")" '{gsub(/__DESCRIPTION__/, r)}1' "$output" > "$output.tmp" && mv "$output.tmp" "$output" with open("docker_run_block.txt", "r", encoding="utf-8") as f:
fi 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"
} }
process_template "docker-compose.template" "docker-compose.yml" process_template "docker-compose.template" "docker-compose.yml"