reorder workflow
Some checks failed
/ release-and-build (push) Failing after 57s

This commit is contained in:
2026-02-14 00:41:06 +01:00
parent 365719dd78
commit f27bd5e0fe

View File

@@ -168,26 +168,36 @@ jobs:
id: update_doc
if: steps.check_changes.outputs.should_build == 'true'
run: |
set -x # Aktiviert Debug-Modus, um den Fehler genau zu sehen
# --- 1. VARIABLEN VORBEREITEN ---
export TZ=Europe/Berlin
CURRENT_TIME=$(date '+%d.%m.%Y %H:%M')
BUILD_TAG=${{ steps.prep.outputs.docker_tag }}
FULL_URL=${{ steps.prep.outputs.image_name }}
REPO_PURE=${{ steps.prep.outputs.repo_pure }}
BASE_IMAGE=${{ steps.prep.outputs.base_image }}
BUILD_TAG="${{ steps.prep.outputs.docker_tag }}"
FULL_URL="${{ steps.prep.outputs.image_name }}"
REPO_PURE="${{ steps.prep.outputs.repo_pure }}"
BASE_IMAGE="${{ steps.prep.outputs.base_image }}"
# Umgebungsvariablen laden
# Sicherstellen, dass buildargs.env da ist
if [ ! -f "buildargs.env" ]; then echo "❌ buildargs.env fehlt!"; exit 1; fi
# Env sauber laden (ohne Subshell-Source)
grep -v '^#' buildargs.env | sed 's/\r$//' > cleaned_env.sh
set -a
source <(grep -v '^#' buildargs.env | sed 's/\r$//')
source ./cleaned_env.sh
set +a
if [ -f "Dockerfile.aarch64" ]; then ARM_STATUS="✅ Aktiv (eigenes Dockerfile)"; else ARM_STATUS="❌ Nicht unterstützt"; fi
COMMIT_MSG=$(echo "${{ github.event.head_commit.message }}" | sed 's/\[skip ci\]//g' | xargs)
# COMMIT_MSG sicher abfangen (verhindert Fehler durch Sonderzeichen)
cat << 'EOF' > commit_msg.txt
${{ gitea.event.head_commit.message }}
EOF
COMMIT_MSG=$(sed 's/\[skip ci\]//g' commit_msg.txt | xargs)
# --- 2. TEMPLATES LADEN ---
# || true verhindert Abbruch, falls Datei fehlt (sollte aber nicht passieren)
wget -q https://git.pi-farm.de/pi-farm/templates/raw/branch/main/README.template -O README.template || echo "Warnung: README.template nicht geladen"
wget -q https://git.pi-farm.de/pi-farm/templates/raw/branch/main/docker-compose.template -O docker-compose.template || echo "Warnung: docker-compose.template nicht geladen"
wget -q https://git.pi-farm.de/pi-farm/templates/raw/branch/main/README.template -O README.template || echo "Templates konnten nicht geladen werden"
wget -q https://git.pi-farm.de/pi-farm/templates/raw/branch/main/docker-compose.template -O docker-compose.template || echo "Templates konnten nicht geladen werden"
# --- 3. VERSION HISTORY UPDATE ---
NEW_ROW="| **$BUILD_TAG** | $CURRENT_TIME | $COMMIT_MSG ✅ |"
@@ -202,96 +212,95 @@ jobs:
HISTORY_CONTENT=$(cat VERSION.history)
# --- 4. ENV / PORTS / VOL BLÖCKE GENERIEREN ---
# WICHTIG: "|| true" am Ende der greps verhindert exit code 1 bei leeren Ergebnissen
ENV_BLOCK_CONTENT=""
env_vars=$(grep '^ENV_' buildargs.env | grep -v '^#' | tr -d '\r' || true)
if [ ! -z "$env_vars" ]; then
if [ -n "$env_vars" ]; then
ENV_BLOCK_CONTENT=" environment:\n"
for line in $env_vars; do
key=$(echo $line | cut -d= -f1); val=$(echo $line | cut -d= -f2-); clean_key=${key#ENV_}
while read -r line; do
[ -z "$line" ] && continue
key=$(echo "$line" | cut -d= -f1); val=$(echo "$line" | cut -d= -f2-); clean_key=${key#ENV_}
ENV_BLOCK_CONTENT="${ENV_BLOCK_CONTENT} - ${clean_key}=${val}\n"
done
done <<< "$env_vars"
fi
PORTS_BLOCK_CONTENT=""
port_vars=$(grep '^PORT_' buildargs.env | grep -v '^#' | tr -d '\r' || true)
if [ ! -z "$port_vars" ]; then
if [ -n "$port_vars" ]; then
PORTS_BLOCK_CONTENT=" ports:\n"
for line in $port_vars; do
val=$(echo $line | cut -d= -f2-); PORTS_BLOCK_CONTENT="${PORTS_BLOCK_CONTENT} - ${val}\n"
done
while read -r line; do
[ -z "$line" ] && continue
val=$(echo "$line" | cut -d= -f2-); PORTS_BLOCK_CONTENT="${PORTS_BLOCK_CONTENT} - ${val}\n"
done <<< "$port_vars"
fi
VOL_BLOCK_CONTENT=""
vol_vars=$(grep '^VOL_' buildargs.env | grep -v '^#' | tr -d '\r' || true)
if [ ! -z "$vol_vars" ]; then
if [ -n "$vol_vars" ]; then
VOL_BLOCK_CONTENT=" volumes:\n"
for line in $vol_vars; do
val=$(echo $line | cut -d= -f2-); VOL_BLOCK_CONTENT="${VOL_BLOCK_CONTENT} - ${val}\n"
done
fi
# --- 5. DOCKER RUN BEFEHL GENERIEREN ---
RUN_CMD="docker run -d \\ \n --name $REPO_PURE \\ \n --restart unless-stopped"
# Hier || true im grep, damit die Pipe nicht platzt
while read -r line; do
if [[ "$line" =~ ^PORT_ ]]; then
val=$(echo $line | cut -d= -f2-)
RUN_CMD="${RUN_CMD} \\ \n -p ${val}"
elif [[ "$line" =~ ^ENV_ ]]; then
key=$(echo $line | cut -d= -f1); clean_key=${key#ENV_}; val=$(echo $line | cut -d= -f2-)
RUN_CMD="${RUN_CMD} \\ \n -e ${clean_key}=${val}"
elif [[ "$line" =~ ^VOL_ ]]; then
val=$(echo $line | cut -d= -f2-)
RUN_CMD="${RUN_CMD} \\ \n -v ${val}"
[ -z "$line" ] && continue
val=$(echo "$line" | cut -d= -f2-); VOL_BLOCK_CONTENT="${VOL_BLOCK_CONTENT} - ${val}\n"
done <<< "$vol_vars"
fi
done < <(grep -E '^(PORT_|ENV_|VOL_)' buildargs.env | grep -v '^#' | sed 's/\r$//' || true)
# --- 5. DOCKER RUN BEFEHL ---
RUN_CMD="docker run -d \\ \n --name $REPO_PURE \\ \n --restart unless-stopped"
all_params=$(grep -E '^(PORT_|ENV_|VOL_)' buildargs.env | grep -v '^#' | sed 's/\r$//' || true)
if [ -n "$all_params" ]; then
while read -r line; do
[ -z "$line" ] && continue
if [[ "$line" =~ ^PORT_ ]]; then
val=$(echo "$line" | cut -d= -f2-); RUN_CMD="${RUN_CMD} \\ \n -p ${val}"
elif [[ "$line" =~ ^ENV_ ]]; then
key=$(echo "$line" | cut -d= -f1); clean_key=${key#ENV_}; val=$(echo "$line" | cut -d= -f2-); RUN_CMD="${RUN_CMD} \\ \n -e ${clean_key}=${val}"
elif [[ "$line" =~ ^VOL_ ]]; then
val=$(echo "$line" | cut -d= -f2-); RUN_CMD="${RUN_CMD} \\ \n -v ${val}"
fi
done <<< "$all_params"
fi
RUN_CMD="${RUN_CMD} \\ \n $FULL_URL:$BUILD_TAG"
DOCKER_RUN_FINAL=$(echo -e "$RUN_CMD")
# --- 6. DOCKER HUB LINK ---
DOCKERHUB_LINK_CONTENT=""
if [[ "$PUSH" == *"dockerhub"* ]]; then
if [[ "${{ steps.prep.outputs.push_targets }}" == *"dockerhub"* ]]; then
DH_USER="${{ secrets.DOCKERHUB_USERNAME }}"
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
# --- 7. TEMPLATE ENGINE ---
# Wir nutzen einen temp-Ordner für die Ersetzungen, um Sonderzeichen-Probleme zu vermeiden
process_template() {
local template=$1; local output=$2
if [ -f "$template" ]; then
> "$output"
while IFS= read -r line || [ -n "$line" ]; do
line="${line//__REPO_NAME__/$REPO_PURE}"
line="${line//__FULL_URL__/$FULL_URL}"
line="${line//__BUILD_TAG__/$BUILD_TAG}"
line="${line//__BASE_IMAGE__/$BASE_IMAGE}"
line="${line//__ARM_STATUS__/$ARM_STATUS}"
line="${line//__CURRENT_DATE__/$CURRENT_TIME}"
line="${line//__HISTORY_CONTENT__/$HISTORY_CONTENT}"
line="${line//__DOCKER_RUN__/$DOCKER_RUN_FINAL}"
line="${line//__DOCKERHUB_LINK__/$DOCKERHUB_LINK_CONTENT}"
# Description
if [[ "$line" == *"__DESCRIPTION__"* ]]; then
echo -e "${DESCRIPTION:-Keine Beschreibung.}" >> "$output"
# Environment
elif [[ "$line" == *"__ENV_BLOCK__"* ]]; then
[ -n "$ENV_BLOCK_CONTENT" ] && echo -e "${ENV_BLOCK_CONTENT}" >> "$output"
# Ports
elif [[ "$line" == *"__PORTS_BLOCK__"* ]]; then
[ -n "$PORTS_BLOCK_CONTENT" ] && echo -e "${PORTS_BLOCK_CONTENT}" >> "$output"
# Volumes
elif [[ "$line" == *"__VOL_BLOCK__"* ]]; then
[ -n "$VOL_BLOCK_CONTENT" ] && echo -e "${VOL_BLOCK_CONTENT}" >> "$output"
# Compose
elif [[ "$line" == *"__COMPOSE_BLOCK__"* ]]; then
[ -f "docker-compose.yml" ] && cat docker-compose.yml >> "$output"
else
echo "$line" >> "$output"
[ ! -f "$template" ] && return
cp "$template" "$output"
# Einfache Ersetzungen
sed -i "s|__REPO_NAME__|$REPO_PURE|g" "$output"
sed -i "s|__FULL_URL__|$FULL_URL|g" "$output"
sed -i "s|__BUILD_TAG__|$BUILD_TAG|g" "$output"
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"
# Komplexe Blöcke über ein temporäres File einfügen (verhindert Shell-Interpretationsfehler)
awk -v r="$HISTORY_CONTENT" '{gsub(/__HISTORY_CONTENT__/, r)}1' "$output" > "$output.tmp" && mv "$output.tmp" "$output"
awk -v r="$DOCKER_RUN_FINAL" '{gsub(/__DOCKER_RUN__/, r)}1' "$output" > "$output.tmp" && mv "$output.tmp" "$output"
awk -v r="$DOCKERHUB_LINK_CONTENT" '{gsub(/__DOCKERHUB_LINK__/, r)}1' "$output" > "$output.tmp" && mv "$output.tmp" "$output"
# Multiline DESCRIPTION & Blocks
if grep -q "__DESCRIPTION__" "$output"; then
awk -v r="$(echo -e "${DESCRIPTION:-Keine Beschreibung.}")" '{gsub(/__DESCRIPTION__/, r)}1' "$output" > "$output.tmp" && mv "$output.tmp" "$output"
fi
done < "$template"
if grep -q "__ENV_BLOCK__" "$output"; then
awk -v r="$(echo -e "$ENV_BLOCK_CONTENT")" '{gsub(/__ENV_BLOCK__/, r)}1' "$output" > "$output.tmp" && mv "$output.tmp" "$output"
fi
# ... analog für Ports und Volumes ...
awk -v r="$(echo -e "$PORTS_BLOCK_CONTENT")" '{gsub(/__PORTS_BLOCK__/, r)}1' "$output" > "$output.tmp" && mv "$output.tmp" "$output"
awk -v r="$(echo -e "$VOL_BLOCK_CONTENT")" '{gsub(/__VOL_BLOCK__/, r)}1' "$output" > "$output.tmp" && mv "$output.tmp" "$output"
# Compose-Inhalt am Ende einfügen, falls das Tag da ist
if grep -q "__COMPOSE_BLOCK__" "$output" && [ -f "docker-compose.yml" ]; then
sed -e '/__COMPOSE_BLOCK__/{r docker-compose.yml' -e 'd;}' "$output" > "$output.tmp" && mv "$output.tmp" "$output"
fi
}
@@ -303,7 +312,6 @@ jobs:
echo "DESCRIPTION<<EOF" >> $GITHUB_ENV
echo -e "$DESCRIPTION" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Push README to Docker Hub
# WICHTIG: Verwende jetzt outputs.push_targets statt env.PUSH
if: steps.check_changes.outputs.should_build == 'true' && contains(steps.prep.outputs.push_targets, 'dockerhub')