|
1 | 1 | 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 | + |
8 | 3 | on:
|
9 | 4 | workflow_dispatch:
|
10 | 5 | inputs:
|
|
16 | 11 | description: "Default version to use for new local working copy."
|
17 | 12 | required: true
|
18 | 13 | default: "X.Y.Z-SNAPSHOT"
|
19 |
| - APP_PATH: |
| 14 | + app-path: |
20 | 15 | type: choice
|
21 | 16 | 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 | + |
25 | 22 | jobs:
|
26 | 23 | release:
|
27 | 24 | runs-on: ubuntu-latest
|
28 | 25 | outputs:
|
29 | 26 | MVN_ARTIFACT_ID: ${{ steps.maven-release-step.outputs.MVN_ARTIFACT_ID }}
|
30 | 27 | 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 |
43 | 30 | 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 | + |
63 | 35 | 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 }} |
79 | 48 |
|
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 |
| - |
92 | 49 | create-github-release:
|
93 |
| - needs: release |
94 |
| - runs-on: ubuntu-latest |
95 |
| - steps: |
| 50 | + needs: release |
| 51 | + runs-on: ubuntu-latest |
| 52 | + steps: |
96 | 53 | - name: Create GitHub Release
|
97 | 54 | id: create_release
|
98 | 55 | uses: softprops/action-gh-release@v2
|
|
0 commit comments