From 43147eb578e57d9738ed21ed574db89c0372b6d0 Mon Sep 17 00:00:00 2001 From: Hans <11695964+hupling@users.noreply.github.com> Date: Tue, 2 Jul 2024 07:39:27 +0200 Subject: [PATCH] Update release-maven-image.yml --- .github/workflows/release-maven-image.yml | 99 +++++++---------------- 1 file changed, 28 insertions(+), 71 deletions(-) diff --git a/.github/workflows/release-maven-image.yml b/.github/workflows/release-maven-image.yml index 7a33228..2580876 100644 --- a/.github/workflows/release-maven-image.yml +++ b/.github/workflows/release-maven-image.yml @@ -1,10 +1,5 @@ name: release-maven-image -env: - JAVA_VERSION: 17 - NODE_VERSION: 20 - REGISTRY: ghcr.io - TZ: Europe/Berlin # timezone - + on: workflow_dispatch: inputs: @@ -16,83 +11,45 @@ on: description: "Default version to use for new local working copy." required: true default: "X.Y.Z-SNAPSHOT" - APP_PATH: + app-path: type: choice description: Service-Name - options: - - /sps-backend - - /sps-frontend + required: true + options: + - /sps-backend # todo: muss angepasst werden. eigenen Ordner verwenden + - /sps-frontend # todo: muss angepasst werden. eigenen Ordner verwenden + jobs: release: runs-on: ubuntu-latest outputs: MVN_ARTIFACT_ID: ${{ steps.maven-release-step.outputs.MVN_ARTIFACT_ID }} steps: - # Checkout source code, set up Java, etc. Then... - - name: Checkout code - uses: actions/checkout@v4 - - name: Set up JDK 17 - uses: actions/setup-java@v4 - with: - java-version: ${{ env.JAVA_VERSION }} - distribution: "temurin" - cache: "maven" - cache-dependency-path: ".${{ github.event.inputs.APP_PATH}}/pom.xml" - - name: Set up Node.js - uses: actions/setup-node@v4 + - id: maven-release-step + uses: it-at-m/.github/.github/actions/action-maven-release@reuseable-workflow with: - node-version: ${{ env.NODE_VERSION }} - - name: Maven Release Step - id: maven-release-step - run: | - git config --global user.email "github-actions@github.com" - git config --global user.name "GitHub Actions" - MVN_ARTIFACT_ID=$(mvn -f .${{github.event.inputs.APP_PATH}}/pom.xml org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate -Dexpression=project.artifactId -q -DforceStdout) - echo $MVN_ARTIFACT_ID - echo "MVN_ARTIFACT_ID=$MVN_ARTIFACT_ID" >> $GITHUB_OUTPUT - mvn release:prepare -f .${{github.event.inputs.APP_PATH}}/pom.xml -B -Dpassword=${GITLAB_ACCESS_TOKEN_PW} -DreleaseVersion=${{ github.event.inputs.releaseVersion }} -DdevelopmentVersion=${{ github.event.inputs.developmentVersion }} - mvn release:perform -f .${{github.event.inputs.APP_PATH}}/pom.xml -Darguments="-Dmaven.deploy.skip=true" - - name: 'Upload Artifact' - uses: actions/upload-artifact@v4 - with: - name: target - path: "**/target" - retention-days: 5 - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + app-path: "${{ env.app-path }}" + releaseVersion: releaseVersion + developmentVersion: developmentVersion + build-image: - needs: release - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Download a single artifact - uses: actions/download-artifact@v4 - with: - name: target - - name: Login to Registry - uses: docker/login-action@v3 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} + runs-on: ubuntu-latest + needs: build-maven + if: github.ref == 'refs/heads/main' + steps: + - uses: it-at-m/.github/.github/actions/action-build-image@reuseable-workflow + with: + app-path: "${{ env.app-path }}" + registry-password: ${{ secrets.GITHUB_TOKEN }} + registry: ghcr.io + registry-username: ${{ github.actor }} + image-tags: | + type=semver,pattern={{version}},value=${{ github.event.inputs.releaseVersion }} - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@v5 - with: - images: ${{ env.REGISTRY }}/${{ github.repository }}${{ github.event.inputs.APP_PATH }} - - name: Build and push image - uses: docker/build-push-action@v4 - with: - context: .${{ github.event.inputs.APP_PATH }} - push: true - tags: ${{ env.REGISTRY }}/${{ github.repository }}${{ github.event.inputs.APP_PATH }}:${{ github.event.inputs.releaseVersion }} - create-github-release: - needs: release - runs-on: ubuntu-latest - steps: + needs: release + runs-on: ubuntu-latest + steps: - name: Create GitHub Release id: create_release uses: softprops/action-gh-release@v2