Skip to content
name: Build and publish native (GraalVM) images
on:
push:
branches:
- main
tags:
- 'v*.*.*'
pull_request:
branches:
- main
jobs:
build_native_docker_image:
name: Build and publish the native (GraalVM) Docker image
runs-on: ubuntu-22.04
env:
DOCKER_IMAGE_NAME: '${{ github.repository_owner }}/jhipster-lite-native'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5.5.1
with:
images: ${{ env.DOCKER_IMAGE_NAME }}
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: 'oracle'
java-version: '21'
check-latest: false
- name: Cache local Maven repository
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Build application with Buildpacks
run: |
./mvnw -Pnative -DskipTests clean spring-boot:build-image -Dspring-boot.build-image.imageName=${{ env.DOCKER_IMAGE_NAME }} -Ddevelocity.cache.remote.enabled=false
- name: Test native image
working-directory: tests-ci
run: ./start_docker_container.sh ${{ env.DOCKER_IMAGE_NAME }}
- name: Login to Docker Registry
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
uses: docker/login-action@v3.3.0
id: login-hub
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Tag the native (GraalVM) Docker image and push it
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
run: |
docker tag ${{ env.DOCKER_IMAGE_NAME }} ${{ env.DOCKER_IMAGE_NAME }}:latest
docker tag ${{ env.DOCKER_IMAGE_NAME }} ${{ env.DOCKER_IMAGE_NAME }}:${{ github.ref_name }}
docker push --all-tags ${{ env.DOCKER_IMAGE_NAME }}