name: Build-und-Deploy

on:
  push:
    branches:
      - master

jobs:
  build-and-deploy:
    runs-on: ubuntu-latest

    steps:
      - name: 🧾 Repository auschecken
        uses: actions/checkout@v3

      - name: 🛠 Baue das Projekt (ohne Tests)
        run: ./gradlew clean build -x test

      - name: 📦 Kopiere JAR für Docker
        run: cp build/libs/MyTimeTracker-0.0.1-SNAPSHOT.jar ./app.jar

      - name: 🐳 Docker Compose Build & Deploy
        run: docker compose -f ./compose.yml up -d --build

      - name: 🧹 Clean Up (optional)
        if: always()
        run: docker system prune -f