Build and publish latest image #21
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and publish latest image | |
on: | |
workflow_dispatch: | |
env: | |
IMAGE_NAME: smartparkingconfig | |
DOCKERHUB_USERNAME: starwit | |
DOCKERHUB_ORG: starwitorg | |
VERSION_BUILD: 0.0.0 | |
jobs: | |
build: | |
name: "Build and publish with build number" | |
runs-on: [self-hosted, linux, X64] | |
steps: | |
- name: checkout | |
uses: actions/checkout@v4 | |
- name: Set up JDK 21 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: 21 | |
- name: Set up Maven | |
uses: stCarolas/[email protected] | |
with: | |
maven-version: 3.9.2 | |
- name: setup node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- run: npm --version | |
- run: node --version | |
- run: mvn --version | |
- name: npm install | |
run: | | |
if [ -d "webclient/app" ]; then | |
cd webclient/app | |
npm install | |
fi | |
- name: Build with Maven | |
run: mvn clean -B package -P frontend --file pom.xml | |
env: | |
CI: false | |
- name: get version from pom.xml | |
run: | | |
echo "VERSION_BUILD=$( mvn help:evaluate -Dexpression=project.version -q -DforceStdout )" >> $GITHUB_ENV | |
publish_docker: | |
name: "Build and publish docker" | |
needs: build | |
runs-on: [self-hosted, linux, X64] | |
steps: | |
- name: Set up Maven | |
uses: stCarolas/[email protected] | |
with: | |
maven-version: 3.9.2 | |
- 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 | |
tags: ${{ env.DOCKERHUB_ORG }}/${{ env.IMAGE_NAME }}:${{ env.VERSION_BUILD }}-${{ github.run_number }} |