From da290eb9048e6be0d982fc3f910d1356ffd56d1a Mon Sep 17 00:00:00 2001 From: veenm Date: Mon, 2 Mar 2026 21:37:32 +0100 Subject: [PATCH] PIPELINE EFFICIENCY FIX --- .gitea/workflows/new-image.yml | 36 ++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/.gitea/workflows/new-image.yml b/.gitea/workflows/new-image.yml index f59e1e0..043b59b 100644 --- a/.gitea/workflows/new-image.yml +++ b/.gitea/workflows/new-image.yml @@ -2,17 +2,15 @@ name: Build and Push Quarkus Image on: push: - branches: [ "main" ] # Pas aan naar jouw hoofdbranch als dit 'master' is + branches: [ "main" ] env: - # VERVANG DIT door de domeinnaam van jouw Gitea server (zonder https://) REGISTRY: git.melvanveen.nl - # Dit pakt automatisch de eigenaar en naam van de repo (bijv. username/quarkus-app) IMAGE_NAME: ${{ github.repository }} jobs: build-and-push: - runs-on: ubuntu-latest # Zorg dat je Gitea runner Docker ondersteunt + runs-on: ubuntu-latest permissions: contents: read @@ -25,16 +23,30 @@ jobs: - name: Java 21 instellen uses: actions/setup-java@v4 with: - java-version: '21' # Pas aan naar 17 als je Java 17 gebruikt + java-version: '21' distribution: 'temurin' + cache: 'maven' + + - name: Versie bepalen en pom.xml updaten + run: | + NEW_VERSION="1.0.${{ github.run_number }}" + echo "APP_VERSION=$NEW_VERSION" >> $GITHUB_ENV + ./mvnw versions:set -DnewVersion=$NEW_VERSION -DgenerateBackupPoms=false + + - name: Cache SonarQube packages + uses: actions/cache@v4 + with: + path: ~/.sonar/cache + key: ${{ runner.os }}-sonar + restore-keys: ${{ runner.os }}-sonar - name: SonarQube Analyse uitvoeren - # Maven leest de configuratie uit pom.xml, we geven alleen het secret token mee via de command line run: | ./mvnw clean verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar \ - -Dsonar.token=${{ secrets.SONAR_TOKEN }} + -Dsonar.token=${{ secrets.SONAR_TOKEN }} \ + -Dsonar.projectVersion=${{ env.APP_VERSION }} - - name: Quarkus applicatie bouwen (.jar genereren) + - name: Quarkus applicatie bouwen run: ./mvnw clean package -DskipTests - name: Inloggen op Gitea Container Registry @@ -42,17 +54,17 @@ jobs: with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} - # Gitea genereert automatisch dit token, net als GitHub. password: ${{ secrets.CR_PAT }} - name: Docker image bouwen en pushen uses: docker/build-push-action@v5 with: context: . - # We gebruiken de standaard JVM Dockerfile van Quarkus file: src/main/docker/Dockerfile.jvm push: true - # We taggen de image met 'latest' én met de specifieke commit-hash tags: | ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }} \ No newline at end of file + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }} + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.APP_VERSION }} + cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache + cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache,mode=max \ No newline at end of file