diff --git a/.gitea/workflows/build-and-push.yaml b/.gitea/workflows/build-and-push.yaml index 0c77446..3e115fe 100644 --- a/.gitea/workflows/build-and-push.yaml +++ b/.gitea/workflows/build-and-push.yaml @@ -294,35 +294,36 @@ jobs: done fi - # --- TEMPLATE ENGINE --- + # DOCKER RUN GENERATOR + RUN_CMD="docker run -d \\ \n --name ${REPO_PURE} \\ \n --restart unless-stopped" + # Variablen aus buildargs.env für RUN-Befehl sammeln + # Wir nutzen hier direkt die exportierten Werte + while read -r line; do + [[ $line =~ ^PORT_ ]] && val="${line#*=}" && RUN_CMD="${RUN_CMD} \\ \n -p ${val}" + if [[ $line =~ ^ENV_ ]]; then + key="${line%%=*}"; clean_key="${key#ENV_}"; val="${!key}" + RUN_CMD="${RUN_CMD} \\ \n -e ${clean_key}=${val}" + fi + [[ $line =~ ^VOL_ ]] && val="${line#*=}" && RUN_CMD="${RUN_CMD} \\ \n -v ${val}" + done < <(grep -E '^(PORT_|ENV_|VOL_)' buildargs.env | grep -v '^#' | sed 's/\r$//') + + RUN_CMD="${RUN_CMD} \\ \n ${FULL_URL}:${BUILD_TAG}" + DOCKER_RUN_FINAL=$(echo -e "$RUN_CMD") + + # TEMPLATE ENGINE process_template() { local template=$1; local output=$2 if [ -f "$template" ]; then > "$output" while IFS= read -r line || [ -n "$line" ]; do - # Ersetzung deiner ursprünglichen Platzhalter line="${line//__REPO_NAME__/$REPO_PURE}" line="${line//__FULL_URL__/$FULL_URL}" line="${line//__BUILD_TAG__/$BUILD_TAG}" - - # Ersetzung der neuen Block-Platzhalter - line="${line//__CURRENT_DATE__/$CURRENT_TIME}" - line="${line//__BUILD_DATE__/$BUILD_DATE_ONLY}" - line="${line//__HISTORY_CONTENT__/$HISTORY_CONTENT}" - line="${line//__ARM_STATUS__/$ARM_STATUS}" line="${line//__BASE_IMAGE__/$BASE_IMAGE}" - - # Block Injections - if [[ "$line" == *"__ENV_BLOCK__"* ]]; then - if [ -n "$ENV_BLOCK_CONTENT" ]; then echo -e "${ENV_BLOCK_CONTENT}" >> "$output"; fi - elif [[ "$line" == *"__PORTS_BLOCK__"* ]]; then - if [ -n "$PORTS_BLOCK_CONTENT" ]; then echo -e "${PORTS_BLOCK_CONTENT}" >> "$output"; fi - elif [[ "$line" == *"__VOL_BLOCK__"* ]]; then - if [ -n "$VOL_BLOCK_CONTENT" ]; then echo -e "${VOL_BLOCK_CONTENT}" >> "$output"; fi - else - echo "$line" >> "$output" - fi + line="${line//__DOCKER_RUN__/$DOCKER_RUN_FINAL}" # <--- NEU + # ... restliche Block-Injections ... + echo "$line" >> "$output" done < "$template" fi }