.gitea/workflows/build-and-push.yaml aktualisiert
build-and-push.yaml / release-and-build (push) Failing after 22m23s
build-and-push.yaml / release-and-build (push) Failing after 22m23s
This commit is contained in:
1 parent
d25f1697c5
commit
a53403fbea
1 file changed
+114
-114
@@ -204,134 +204,132 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
set -x
|
set -x
|
||||||
|
|
||||||
export TZ=Europe/Berlin
|
export TZ=Europe/Berlin
|
||||||
CURRENT_TIME=$(date '+%d.%m.%Y %H:%M')
|
CURRENT_TIME=$(date '+%d.%m.%Y %H:%M')
|
||||||
BUILD_TAG="${{ steps.prep.outputs.docker_tag }}"
|
BUILD_TAG="${{ steps.prep.outputs.docker_tag }}"
|
||||||
FULL_URL="${{ steps.prep.outputs.image_name }}"
|
FULL_URL="${{ steps.prep.outputs.image_name }}"
|
||||||
REPO_PURE="${{ steps.prep.outputs.repo_pure }}"
|
REPO_PURE="${{ steps.prep.outputs.repo_pure }}"
|
||||||
BASE_IMAGE="${{ steps.prep.outputs.base_image }}"
|
BASE_IMAGE="${{ steps.prep.outputs.base_image }}"
|
||||||
|
|
||||||
if [ ! -f "buildargs.env" ]; then echo "❌ buildargs.env missing!"; exit 1; fi
|
if [ ! -f "buildargs.env" ]; then echo "❌ buildargs.env missing!"; exit 1; fi
|
||||||
|
|
||||||
grep -v '^#' buildargs.env | sed 's/\r$//' > cleaned_env.sh
|
grep -v '^#' buildargs.env | sed 's/\r$//' > cleaned_env.sh
|
||||||
set -a
|
set -a
|
||||||
source ./cleaned_env.sh
|
source ./cleaned_env.sh
|
||||||
set +a
|
set +a
|
||||||
|
|
||||||
if [ -f "Dockerfile.aarch64" ]; then ARM_STATUS="✅ Active"; else ARM_STATUS="❌ Not supported"; fi
|
if [ -f "Dockerfile.aarch64" ]; then ARM_STATUS="✅ Active"; else ARM_STATUS="❌ Not supported"; fi
|
||||||
|
|
||||||
cat << 'EOF' > commit_msg.txt
|
# Commit-Message ohne fehleranfälliges Here-Doc einlesen
|
||||||
${{ gitea.event.head_commit.message }}
|
RAW_COMMIT_MSG="${{ gitea.event.head_commit.message }}"
|
||||||
EOF
|
COMMIT_MSG=$(echo "$RAW_COMMIT_MSG" | sed 's/\[skip ci\]//g' | tr -d '\r\n' | xargs)
|
||||||
COMMIT_MSG=$(sed 's/\[skip ci\]//g' commit_msg.txt | xargs)
|
|
||||||
|
|
||||||
# 1. Authentifizierter Download der Templates via curl (-f bricht bei HTTP-Fehlern ab)
|
# 1. Authentifizierter Download der Templates
|
||||||
TOKEN="${{ secrets.RUNNER_TOKEN }}"
|
TOKEN="${{ secrets.RUNNER_TOKEN }}"
|
||||||
curl -sSLf -H "Authorization: token $TOKEN" \
|
curl -sSLf -H "Authorization: token $TOKEN" \
|
||||||
"https://git.pi-farm.de/pi-farm/templates/raw/branch/dev/README.template" \
|
"https://git.pi-farm.de/pi-farm/templates/raw/branch/dev/README.template" \
|
||||||
-o README.template || echo "Warnung: README Template konnte nicht geladen werden"
|
-o README.template || echo "Warnung: README Template konnte nicht geladen werden"
|
||||||
|
|
||||||
curl -sSLf -H "Authorization: token $TOKEN" \
|
curl -sSLf -H "Authorization: token $TOKEN" \
|
||||||
"https://git.pi-farm.de/pi-farm/templates/raw/branch/dev/docker-compose.template" \
|
"https://git.pi-farm.de/pi-farm/templates/raw/branch/dev/docker-compose.template" \
|
||||||
-o docker-compose.template || echo "Warnung: Compose Template konnte nicht geladen werden"
|
-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
|
# 2. Sicherheitsprüfung auf HTML-Login-Seite
|
||||||
for t_file in README.template docker-compose.template; do
|
for t_file in README.template docker-compose.template; do
|
||||||
if [ -f "$t_file" ] && grep -qi "<!DOCTYPE html>" "$t_file"; then
|
if [ -f "$t_file" ] && grep -qi "<!DOCTYPE html>" "$t_file"; then
|
||||||
echo "❌ FEHLER: $t_file ist eine HTML-Loginseite! Download verworfen."
|
echo "❌ FEHLER: $t_file ist eine HTML-Loginseite! Download verworfen."
|
||||||
rm -f "$t_file"
|
rm -f "$t_file"
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
NEW_ROW="| **$BUILD_TAG** | $CURRENT_TIME | $COMMIT_MSG ✅ |"
|
|
||||||
if [ -f "VERSION.history" ]; then
|
|
||||||
grep -v "| **$BUILD_TAG** |" VERSION.history > VERSION.history.tmp || true
|
|
||||||
echo "$NEW_ROW" > VERSION.history
|
|
||||||
cat VERSION.history.tmp >> VERSION.history
|
|
||||||
rm VERSION.history.tmp
|
|
||||||
else
|
|
||||||
echo "$NEW_ROW" > VERSION.history
|
|
||||||
fi
|
fi
|
||||||
HISTORY_CONTENT=$(cat VERSION.history)
|
done
|
||||||
|
|
||||||
ENV_BLOCK_CONTENT=""
|
NEW_ROW="| **$BUILD_TAG** | $CURRENT_TIME | $COMMIT_MSG ✅ |"
|
||||||
env_vars=$(grep '^ENV_' buildargs.env | grep -v '^#' | tr -d '\r' || true)
|
if [ -f "VERSION.history" ]; then
|
||||||
if [ -n "$env_vars" ]; then
|
grep -v "| **$BUILD_TAG** |" VERSION.history > VERSION.history.tmp || true
|
||||||
ENV_BLOCK_CONTENT=" environment:\n"
|
echo "$NEW_ROW" > VERSION.history
|
||||||
|
cat VERSION.history.tmp >> VERSION.history
|
||||||
|
rm VERSION.history.tmp
|
||||||
|
else
|
||||||
|
echo "$NEW_ROW" > VERSION.history
|
||||||
|
fi
|
||||||
|
HISTORY_CONTENT=$(cat VERSION.history)
|
||||||
|
|
||||||
|
ENV_BLOCK_CONTENT=""
|
||||||
|
env_vars=$(grep '^ENV_' buildargs.env | grep -v '^#' | tr -d '\r' || true)
|
||||||
|
if [ -n "$env_vars" ]; then
|
||||||
|
ENV_BLOCK_CONTENT=" environment:\n"
|
||||||
|
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 <<< "$env_vars"
|
||||||
|
fi
|
||||||
|
|
||||||
|
PORTS_BLOCK_CONTENT=""
|
||||||
|
port_vars=$(grep '^PORT_' buildargs.env | grep -v '^#' | tr -d '\r' || true)
|
||||||
|
if [ -n "$port_vars" ]; then
|
||||||
|
PORTS_BLOCK_CONTENT=" ports:\n"
|
||||||
|
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 [ -n "$vol_vars" ]; then
|
||||||
|
VOL_BLOCK_CONTENT=" volumes:\n"
|
||||||
|
while read -r line; do
|
||||||
|
[ -z "$line" ] && continue
|
||||||
|
val=$(echo "$line" | cut -d= -f2-); VOL_BLOCK_CONTENT="${VOL_BLOCK_CONTENT} - ${val}\n"
|
||||||
|
done <<< "$vol_vars"
|
||||||
|
fi
|
||||||
|
|
||||||
|
{
|
||||||
|
echo "docker run -d \\"
|
||||||
|
echo " --name $REPO_PURE \\"
|
||||||
|
echo " --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
|
while read -r line; do
|
||||||
[ -z "$line" ] && continue
|
[ -z "$line" ] && continue
|
||||||
key=$(echo "$line" | cut -d= -f1); val=$(echo "$line" | cut -d= -f2-); clean_key=${key#ENV_}
|
if [[ "$line" =~ ^PORT_ ]]; then
|
||||||
ENV_BLOCK_CONTENT="${ENV_BLOCK_CONTENT} - ${clean_key}=${val}\n"
|
val=$(echo "$line" | cut -d= -f2-)
|
||||||
done <<< "$env_vars"
|
echo " -p ${val} \\"
|
||||||
|
elif [[ "$line" =~ ^ENV_ ]]; then
|
||||||
|
key=$(echo "$line" | cut -d= -f1); clean_key=${key#ENV_}; val=$(echo "$line" | cut -d= -f2-)
|
||||||
|
echo " -e ${clean_key}=${val} \\"
|
||||||
|
elif [[ "$line" =~ ^VOL_ ]]; then
|
||||||
|
val=$(echo "$line" | cut -d= -f2-)
|
||||||
|
echo " -v ${val} \\"
|
||||||
|
fi
|
||||||
|
done <<< "$all_params"
|
||||||
fi
|
fi
|
||||||
|
echo " $FULL_URL:$BUILD_TAG"
|
||||||
|
} > docker_run_block.txt
|
||||||
|
|
||||||
PORTS_BLOCK_CONTENT=""
|
DOCKERHUB_LINK_CONTENT=""
|
||||||
port_vars=$(grep '^PORT_' buildargs.env | grep -v '^#' | tr -d '\r' || true)
|
if [[ "${{ steps.prep.outputs.push_targets }}" == *"dockerhub"* ]]; then
|
||||||
if [ -n "$port_vars" ]; then
|
DH_USER="${{ secrets.DOCKERHUB_USERNAME }}"
|
||||||
PORTS_BLOCK_CONTENT=" ports:\n"
|
DOCKERHUB_LINK_CONTENT="[](https://hub.docker.com/r/${DH_USER}/${REPO_PURE})"
|
||||||
while read -r line; do
|
fi
|
||||||
[ -z "$line" ] && continue
|
|
||||||
val=$(echo "$line" | cut -d= -f2-); PORTS_BLOCK_CONTENT="${PORTS_BLOCK_CONTENT} - ${val}\n"
|
|
||||||
done <<< "$port_vars"
|
|
||||||
fi
|
|
||||||
|
|
||||||
VOL_BLOCK_CONTENT=""
|
process_template() {
|
||||||
vol_vars=$(grep '^VOL_' buildargs.env | grep -v '^#' | tr -d '\r' || true)
|
local template=$1; local output=$2
|
||||||
if [ -n "$vol_vars" ]; then
|
[ ! -f "$template" ] && return
|
||||||
VOL_BLOCK_CONTENT=" volumes:\n"
|
cp "$template" "$output"
|
||||||
while read -r line; do
|
|
||||||
[ -z "$line" ] && continue
|
|
||||||
val=$(echo "$line" | cut -d= -f2-); VOL_BLOCK_CONTENT="${VOL_BLOCK_CONTENT} - ${val}\n"
|
|
||||||
done <<< "$vol_vars"
|
|
||||||
fi
|
|
||||||
|
|
||||||
{
|
export REPO_PURE FULL_URL BUILD_TAG BASE_IMAGE ARM_STATUS CURRENT_TIME \
|
||||||
echo "docker run -d \\"
|
HISTORY_CONTENT DOCKERHUB_LINK_CONTENT ENV_BLOCK_CONTENT \
|
||||||
echo " --name $REPO_PURE \\"
|
PORTS_BLOCK_CONTENT VOL_BLOCK_CONTENT DESCRIPTION
|
||||||
echo " --restart unless-stopped \\"
|
|
||||||
|
|
||||||
all_params=$(grep -E '^(PORT_|ENV_|VOL_)' buildargs.env | grep -v '^#' | sed 's/\r$//' || true)
|
python3 -c '
|
||||||
if [ -n "$all_params" ]; then
|
|
||||||
while read -r line; do
|
|
||||||
[ -z "$line" ] && continue
|
|
||||||
if [[ "$line" =~ ^PORT_ ]]; then
|
|
||||||
val=$(echo "$line" | cut -d= -f2-)
|
|
||||||
echo " -p ${val} \\"
|
|
||||||
elif [[ "$line" =~ ^ENV_ ]]; then
|
|
||||||
key=$(echo "$line" | cut -d= -f1); clean_key=${key#ENV_}; val=$(echo "$line" | cut -d= -f2-)
|
|
||||||
echo " -e ${clean_key}=${val} \\"
|
|
||||||
elif [[ "$line" =~ ^VOL_ ]]; then
|
|
||||||
val=$(echo "$line" | cut -d= -f2-)
|
|
||||||
echo " -v ${val} \\"
|
|
||||||
fi
|
|
||||||
done <<< "$all_params"
|
|
||||||
fi
|
|
||||||
echo " $FULL_URL:$BUILD_TAG"
|
|
||||||
} > docker_run_block.txt
|
|
||||||
|
|
||||||
DOCKERHUB_LINK_CONTENT=""
|
|
||||||
if [[ "${{ steps.prep.outputs.push_targets }}" == *"dockerhub"* ]]; then
|
|
||||||
DH_USER="${{ secrets.DOCKERHUB_USERNAME }}"
|
|
||||||
DOCKERHUB_LINK_CONTENT="[](https://hub.docker.com/r/${DH_USER}/${REPO_PURE})"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Template-Verarbeitung via Python (verhindert awk-Abstürze bei Zeilenumbrüchen)
|
|
||||||
process_template() {
|
|
||||||
local template=$1; local output=$2
|
|
||||||
[ ! -f "$template" ] && return
|
|
||||||
cp "$template" "$output"
|
|
||||||
|
|
||||||
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 -c '
|
|
||||||
import os, sys
|
import os, sys
|
||||||
|
|
||||||
output = sys.argv[1]
|
output = sys.argv[1]
|
||||||
|
|
||||||
with open(output, "r", encoding="utf-8") as f:
|
with open(output, "r", encoding="utf-8") as f:
|
||||||
content = f.read()
|
content = f.read()
|
||||||
|
|
||||||
content = content.replace("__REPO_NAME__", os.environ.get("REPO_PURE", ""))
|
content = content.replace("__REPO_NAME__", os.environ.get("REPO_PURE", ""))
|
||||||
content = content.replace("__FULL_URL__", os.environ.get("FULL_URL", ""))
|
content = content.replace("__FULL_URL__", os.environ.get("FULL_URL", ""))
|
||||||
@@ -357,15 +355,17 @@ jobs:
|
|||||||
with open(output, "w", encoding="utf-8") as f:
|
with open(output, "w", encoding="utf-8") as f:
|
||||||
f.write(content)
|
f.write(content)
|
||||||
' "$output"
|
' "$output"
|
||||||
}
|
}
|
||||||
|
|
||||||
process_template "docker-compose.template" "docker-compose.yml"
|
process_template "docker-compose.template" "docker-compose.yml"
|
||||||
process_template "README.template" "README.md"
|
process_template "README.template" "README.md"
|
||||||
|
|
||||||
echo "FINAL_MSG=$COMMIT_MSG" >> $GITHUB_ENV
|
echo "FINAL_MSG=$COMMIT_MSG" >> $GITHUB_ENV
|
||||||
echo "DESCRIPTION<<EOF" >> $GITHUB_ENV
|
{
|
||||||
echo -e "$DESCRIPTION" >> $GITHUB_ENV
|
echo "DESCRIPTION<<EOF"
|
||||||
echo "EOF" >> $GITHUB_ENV
|
echo "$DESCRIPTION"
|
||||||
|
echo "EOF"
|
||||||
|
} >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Push README to Docker Hub
|
- name: Push README to Docker Hub
|
||||||
if: steps.check_changes.outputs.should_build == 'true' && contains(steps.prep.outputs.push_targets, 'dockerhub')
|
if: steps.check_changes.outputs.should_build == 'true' && contains(steps.prep.outputs.push_targets, 'dockerhub')
|
||||||
|
|||||||
Reference in new issue
Block a user