Skip to content

Commit

Permalink
Update release-maven-image.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
hupling authored Jul 2, 2024
1 parent 4a1df95 commit 43147eb
Showing 1 changed file with 28 additions and 71 deletions.
99 changes: 28 additions & 71 deletions .github/workflows/release-maven-image.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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 "[email protected]"
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
Expand Down

0 comments on commit 43147eb

Please sign in to comment.