83 lines
3.0 KiB
YAML
83 lines
3.0 KiB
YAML
name: Build-und-Deploy
|
|
|
|
on:
|
|
push:
|
|
branches: [ master ]
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
container:
|
|
image: ci-java21-node20:latest
|
|
volumes:
|
|
- shared_jar_data:/shared_jar_data
|
|
- shared_trigger_dir:/shared_trigger_dir
|
|
|
|
steps:
|
|
- name: 📥 Repository auschecken
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Container offen halten (60s)
|
|
shell: bash
|
|
run: |
|
|
set -euxo pipefail
|
|
echo "Container: $(hostname)"
|
|
sleep 60
|
|
|
|
- name: 🔎 Umgebung & Volumes
|
|
shell: bash
|
|
run: |
|
|
set -euxo pipefail |& tee -a "/shared_jar_data/ci-$(date +%Y%m%d-%H%M%S).log"
|
|
echo "JAVA_HOME=${JAVA_HOME:-<leer>}" |& tee -a /shared_jar_data/ci-*.log
|
|
java -version |& tee -a /shared_jar_data/ci-*.log
|
|
node -v |& tee -a /shared_jar_data/ci-*.log
|
|
pnpm -v || true |& tee -a /shared_jar_data/ci-*.log
|
|
ls -ld /shared_jar_data /shared_trigger_dir |& tee -a /shared_jar_data/ci-*.log
|
|
|
|
- name: ⚙️ Gradle konfigurieren
|
|
shell: bash
|
|
run: |
|
|
set -euxo pipefail |& tee -a /shared_jar_data/ci-*.log
|
|
mkdir -p ~/.gradle
|
|
{
|
|
echo "org.gradle.daemon=false"
|
|
echo "org.gradle.warning.mode=all"
|
|
echo "org.gradle.java.installations.auto-download=false"
|
|
echo "org.gradle.java.installations.fromEnv=JAVA_HOME"
|
|
echo "org.gradle.java.installations.paths=${JAVA_HOME}"
|
|
} > ~/.gradle/gradle.properties
|
|
cat ~/.gradle/gradle.properties |& tee -a /shared_jar_data/ci-*.log
|
|
|
|
- name: 🔎 Gradle-Info
|
|
shell: bash
|
|
run: |
|
|
set -euxo pipefail |& tee -a /shared_jar_data/ci-*.log
|
|
chmod +x gradlew || true
|
|
./gradlew --version |& tee -a /shared_jar_data/ci-*.log
|
|
./gradlew -q javaToolchains || true |& tee -a /shared_jar_data/ci-*.log
|
|
|
|
- name: 🛠 Baue das Projekt (ohne Tests)
|
|
shell: bash
|
|
run: |
|
|
set -euxo pipefail |& tee -a /shared_jar_data/ci-*.log
|
|
./gradlew clean bootJar -x test --info --stacktrace |& tee -a /shared_jar_data/ci-*.log
|
|
|
|
- name: 📦 Artefakt finden & kopieren
|
|
shell: bash
|
|
run: |
|
|
set -euxo pipefail |& tee -a /shared_jar_data/ci-*.log
|
|
ls -l build/libs |& tee -a /shared_jar_data/ci-*.log
|
|
ARTIFACT="$(ls -t build/libs/*.jar 2>/dev/null | head -n1)"
|
|
test -n "${ARTIFACT}" && test -f "${ARTIFACT}" || { echo "Kein JAR gefunden!"; exit 1; }
|
|
timestamp="$(date +'%Y%m%d-%H%M%S')"
|
|
cp "${ARTIFACT}" /shared_jar_data/MyTimeTracker.jar
|
|
cp "${ARTIFACT}" "/shared_jar_data/archive/MyTimeTracker-${timestamp}.jar"
|
|
ls -l /shared_jar_data /shared_jar_data/archive |& tee -a /shared_jar_data/ci-*.log
|
|
|
|
- name: 🚦 Neustart der Anwendung triggern
|
|
shell: bash
|
|
run: |
|
|
set -euxo pipefail |& tee -a /shared_jar_data/ci-*.log
|
|
mkdir -p /shared_trigger_dir
|
|
touch /shared_trigger_dir/restart-requested
|