Files
mytimetracker/.gitea/workflows/buildAndDeply.yaml
nilzbu eed815c646
Some checks failed
Build-und-Deploy / build (push) Failing after 33s
pipeline
2025-08-09 18:47:35 +02:00

97 lines
3.4 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
name: Build-und-Deploy
on:
push:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
container:
image: ci-java21-node20:latest
steps:
# 1) gitea-Hostname im Job-Container auflösen (ohne 'ip' Paket)
- name: Map gitea into /etc/hosts (ohne ip)
if: ${{ always() }}
shell: bash
run: |
set -euo pipefail
# Default-Gateway aus /proc/net/route lesen (hex) und in dotted quad umrechnen
gw_hex="$(awk '$2=="00000000" {print $3; exit}' /proc/net/route || true)"
if [ -n "${gw_hex:-}" ]; then
gw="$(printf "%d.%d.%d.%d" 0x${gw_hex:6:2} 0x${gw_hex:4:2} 0x${gw_hex:2:2} 0x${gw_hex:0:2})"
else
gw="172.17.0.1" # Fallback: Standard Docker bridge
fi
echo "$gw gitea" >> /etc/hosts
echo "$gw host.docker.internal" >> /etc/hosts || true
getent hosts gitea || true
# 2) Reichweite kurz prüfen (bricht NICHT ab, nur Diagnose)
- name: "Preflight: gitea erreichbar?"
if: ${{ always() }}
continue-on-error: true
shell: bash
run: |
set -euxo pipefail
getent hosts gitea
bash -lc 'echo > /dev/tcp/gitea/3000' && echo "Port 3000 offen" || echo "Port 3000 NICHT offen"
# 3) Normaler Checkout
- name: Checkout
uses: actions/checkout@v4
# 3b) Fallback-Checkout (nur falls Schritt oben rot war)
- name: Fallback-Checkout (manuell)
if: ${{ failure() }}
shell: bash
run: |
set -euxo pipefail
rm -rf .git
git init .
git remote add origin "http://gitea:3000/${{ github.repository }}"
git config --local http.http://gitea:3000/.extraheader "AUTHORIZATION: basic ${{ github.token }}"
git -c protocol.version=2 fetch --depth=1 origin "${{ github.sha }}"
git checkout -qf FETCH_HEAD
# 4) Marker ins Shared-Volume (zeigt, dass Volumes im Job-Container gemountet sind)
- name: Write marker into shared volume
if: ${{ always() }}
shell: bash
run: |
set -euxo pipefail
date | tee /shared_jar_data/PROBE_MARKER.txt
ls -ld /shared_jar_data /shared_trigger_dir || true
# 5) Gradle Wrapper prüfen + Version ausgeben
- name: 🧰 Gradle vorbereiten & Version
shell: bash
run: |
set -euxo pipefail
if [ ! -f ./gradlew ]; then
echo "gradlew fehlt bitte lokal einmal 'gradle wrapper' ausführen und committen."; exit 1
fi
chmod +x ./gradlew
./gradlew --version
# 6) Build ohne Tests
- name: 🏗️ Build (ohne Tests)
shell: bash
run: |
set -euxo pipefail
./gradlew clean build -x test --no-daemon
ls -al build/libs
# 7) Artefakt ins Shared-Volume kopieren (und archivieren)
- name: 📦 JAR ins Shared-Volume kopieren
shell: bash
run: |
set -euxo pipefail
ts="$(date +'%Y%m%d-%H%M%S')"
mkdir -p /shared_jar_data/archive
src="$(ls -1 build/libs/*.jar | head -n1)"
cp "$src" "/shared_jar_data/MyTimeTracker-${ts}.jar"
cp "$src" "/shared_jar_data/archive/MyTimeTracker-${ts}.jar"
echo "Kopiert: $src -> /shared_jar_data/MyTimeTracker-${ts}.jar"
ls -al /shared_jar_data | tail -n +1