Skip to content

Commit 43147eb

Browse files
authored
Update release-maven-image.yml
1 parent 4a1df95 commit 43147eb

File tree

1 file changed

+28
-71
lines changed

1 file changed

+28
-71
lines changed

.github/workflows/release-maven-image.yml

Lines changed: 28 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
name: release-maven-image
2-
env:
3-
JAVA_VERSION: 17
4-
NODE_VERSION: 20
5-
REGISTRY: ghcr.io
6-
TZ: Europe/Berlin # timezone
7-
2+
83
on:
94
workflow_dispatch:
105
inputs:
@@ -16,83 +11,45 @@ on:
1611
description: "Default version to use for new local working copy."
1712
required: true
1813
default: "X.Y.Z-SNAPSHOT"
19-
APP_PATH:
14+
app-path:
2015
type: choice
2116
description: Service-Name
22-
options:
23-
- /sps-backend
24-
- /sps-frontend
17+
required: true
18+
options:
19+
- /sps-backend # todo: muss angepasst werden. eigenen Ordner verwenden
20+
- /sps-frontend # todo: muss angepasst werden. eigenen Ordner verwenden
21+
2522
jobs:
2623
release:
2724
runs-on: ubuntu-latest
2825
outputs:
2926
MVN_ARTIFACT_ID: ${{ steps.maven-release-step.outputs.MVN_ARTIFACT_ID }}
3027
steps:
31-
# Checkout source code, set up Java, etc. Then...
32-
- name: Checkout code
33-
uses: actions/checkout@v4
34-
- name: Set up JDK 17
35-
uses: actions/setup-java@v4
36-
with:
37-
java-version: ${{ env.JAVA_VERSION }}
38-
distribution: "temurin"
39-
cache: "maven"
40-
cache-dependency-path: ".${{ github.event.inputs.APP_PATH}}/pom.xml"
41-
- name: Set up Node.js
42-
uses: actions/setup-node@v4
28+
- id: maven-release-step
29+
uses: it-at-m/.github/.github/actions/action-maven-release@reuseable-workflow
4330
with:
44-
node-version: ${{ env.NODE_VERSION }}
45-
- name: Maven Release Step
46-
id: maven-release-step
47-
run: |
48-
git config --global user.email "[email protected]"
49-
git config --global user.name "GitHub Actions"
50-
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)
51-
echo $MVN_ARTIFACT_ID
52-
echo "MVN_ARTIFACT_ID=$MVN_ARTIFACT_ID" >> $GITHUB_OUTPUT
53-
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 }}
54-
mvn release:perform -f .${{github.event.inputs.APP_PATH}}/pom.xml -Darguments="-Dmaven.deploy.skip=true"
55-
- name: 'Upload Artifact'
56-
uses: actions/upload-artifact@v4
57-
with:
58-
name: target
59-
path: "**/target"
60-
retention-days: 5
61-
env:
62-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31+
app-path: "${{ env.app-path }}"
32+
releaseVersion: releaseVersion
33+
developmentVersion: developmentVersion
34+
6335
build-image:
64-
needs: release
65-
runs-on: ubuntu-latest
66-
steps:
67-
- name: Checkout code
68-
uses: actions/checkout@v4
69-
- name: Download a single artifact
70-
uses: actions/download-artifact@v4
71-
with:
72-
name: target
73-
- name: Login to Registry
74-
uses: docker/login-action@v3
75-
with:
76-
registry: ${{ env.REGISTRY }}
77-
username: ${{ github.actor }}
78-
password: ${{ secrets.GITHUB_TOKEN }}
36+
runs-on: ubuntu-latest
37+
needs: build-maven
38+
if: github.ref == 'refs/heads/main'
39+
steps:
40+
- uses: it-at-m/.github/.github/actions/action-build-image@reuseable-workflow
41+
with:
42+
app-path: "${{ env.app-path }}"
43+
registry-password: ${{ secrets.GITHUB_TOKEN }}
44+
registry: ghcr.io
45+
registry-username: ${{ github.actor }}
46+
image-tags: |
47+
type=semver,pattern={{version}},value=${{ github.event.inputs.releaseVersion }}
7948
80-
- name: Extract metadata (tags, labels) for Docker
81-
id: meta
82-
uses: docker/metadata-action@v5
83-
with:
84-
images: ${{ env.REGISTRY }}/${{ github.repository }}${{ github.event.inputs.APP_PATH }}
85-
- name: Build and push image
86-
uses: docker/build-push-action@v4
87-
with:
88-
context: .${{ github.event.inputs.APP_PATH }}
89-
push: true
90-
tags: ${{ env.REGISTRY }}/${{ github.repository }}${{ github.event.inputs.APP_PATH }}:${{ github.event.inputs.releaseVersion }}
91-
9249
create-github-release:
93-
needs: release
94-
runs-on: ubuntu-latest
95-
steps:
50+
needs: release
51+
runs-on: ubuntu-latest
52+
steps:
9653
- name: Create GitHub Release
9754
id: create_release
9855
uses: softprops/action-gh-release@v2

0 commit comments

Comments
 (0)