Skip to content

Build and publish latest image #4

Build and publish latest image

Build and publish latest image #4

name: Build and publish latest image
on:
workflow_dispatch:
env:
IMAGE_NAME: odp-adapter
DOCKERHUB_USERNAME: starwit
DOCKERHUB_ORG: starwitorg
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
- name: get version from pom.xml
run: |
echo "VERSION_BUILD=$( mvn help:evaluate -Dexpression=project.version -q -DforceStdout )" >> "$GITHUB_OUTPUT"
- name: Build with Maven
run: mvn clean -B package --file pom.xml
env:
CI: false
MAVEN_GPG_PASSPHRASE: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}
MAVEN_GPG_KEY: ${{ secrets.OSSRH_GPG_SECRET_KEY }}
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: 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 }}