Skip to content

build maven/ Docker image and publish with build number #19

build maven/ Docker image and publish with build number

build maven/ Docker image and publish with build number #19

name: build maven/ Docker image and publish with build number
on:
workflow_dispatch:
permissions:
packages: read
env:
IMAGE_NAME: "dave-adminportal"
DOCKERHUB_USERNAME: starwit
DOCKERHUB_ORG: starwitorg
jobs:
build:
name: "Build with Maven"
runs-on: [self-hosted, linux, X64]
outputs:
VERSION_BUILD: ${{ steps.get-version.outputs.VERSION_BUILD }}
steps:
- name: Set up JDK 25
uses: actions/setup-java@v5
with:
distribution: "temurin"
java-version: 25
- name: Set up Maven
uses: stCarolas/setup-maven@v5
with:
maven-version: 3.9.12
- name: setup node
uses: actions/setup-node@v6
with:
node-version: 24
- run: npm --version
- run: node --version
- run: mvn --version
- name: checkout
uses: actions/checkout@v4
with:
fetch-depth: "0"
- name: Build with Maven
run: mvn clean -B package --file pom.xml
env:
CI: false
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: get version from pom.xml
id: get-version
run: |
echo "VERSION_BUILD=$( mvn org.apache.maven.plugins:maven-help-plugin:3.5.1:evaluate -Dexpression=project.version -q -DforceStdout )" >> "$GITHUB_OUTPUT"
publish_docker:
name: "Build and publish docker"
needs: build
runs-on: [self-hosted, linux, X64]
env:
VERSION_BUILD: ${{ needs.build.outputs.VERSION_BUILD }}
steps:
- name: "echo version"
run: |
echo "Version is $VERSION_BUILD"
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ env.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true
sbom: true
provenance: mode=max
tags: ${{ env.DOCKERHUB_ORG }}/${{ env.IMAGE_NAME }}:${{ env.VERSION_BUILD }}-${{ github.run_number }}
publish_helm:
name: "Publish helm chart"
needs: build
runs-on: [self-hosted, linux, X64]
steps:
- name: get helm
uses: azure/setup-helm@v4
- name: login to Helm registry
run: helm registry login registry-1.docker.io -u starwit -p ${{ secrets.DOCKERHUB_TOKEN }}
- name: run helm update
working-directory: apigateway/target/helm/dave-admin-portal
run: helm dep update
- name: run helm package
working-directory: apigateway/target/helm
run: helm package dave-admin-portal
- name: get version number
working-directory: apigateway/target/helm/dave-admin-portal
run: |
echo "HELM_VERSION=$(grep version: Chart.yaml | head -1 | awk '{print $2}')" >> $GITHUB_ENV
- name: run helm push
working-directory: apigateway/target/helm
run: helm push dave-admin-portal-chart-${{ env.HELM_VERSION }}.tgz oci://registry-1.docker.io/starwitorg