Skip to content

Build GraalVM JRE Docker Image #134

Build GraalVM JRE Docker Image

Build GraalVM JRE Docker Image #134

Workflow file for this run

name: Build GraalVM JRE Docker Image
on:
push:
branches:
- main
workflow_dispatch:
schedule:
# Runs every day at midnight (UTC)
- cron: "0 0 * * *"
jobs:
check-and-build:
runs-on: ubuntu-latest
strategy:
matrix:
java_version: [17, 21, 22, 23]
continue-on-error: true # Allow individual jobs to fail without stopping other jobs
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
install: true
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y curl grep sed
- name: Log in to GitHub Container Registry
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Check latest GraalVM version for Java ${{ matrix.java_version }}
id: check_version
run: |
JAVA_VERSION=${{ matrix.java_version }}
RELEASE_NOTES_URL="https://docs.oracle.com/en/graalvm/jdk/$JAVA_VERSION/docs/release-notes/"
LATEST_VERSION=$(curl -s "$RELEASE_NOTES_URL" | grep -oE "[0-9]+\.[0-9]+\.[0-9]+" | grep "^$JAVA_VERSION" | head -n 1)
if [ -z "$LATEST_VERSION" ]; then
LATEST_VERSION="${JAVA_VERSION}.0.0"
echo "No patch version found. Defaulting to: $LATEST_VERSION"
else
echo "Latest GraalVM version for Java $JAVA_VERSION: $LATEST_VERSION"
fi
echo "Latest GraalVM version for Java $JAVA_VERSION: $LATEST_VERSION"
# Use docker manifest inspect to check if the image already exists
if docker manifest inspect "ghcr.io/${{ github.repository_owner }}/graalvm-oracle-jre:$LATEST_VERSION" > /dev/null 2>&1; then
echo "Docker image with Tag $LATEST_VERSION already exists."
echo "new_version=false" >> $GITHUB_ENV
else
echo "New version detected for Java $LATEST_VERSION"
echo "new_version=true" >> $GITHUB_ENV
echo "LATEST_VERSION=$LATEST_VERSION" >> $GITHUB_ENV
echo "JAVA_VERSION=$JAVA_VERSION" >> $GITHUB_ENV
fi
- name: Build and push Docker image
if: env.new_version == 'true'
uses: docker/build-push-action@v6
env:
GRAALVM_VERSION: ${{ env.LATEST_VERSION }}
JAVA_VERSION: ${{ matrix.java_version }}
with:
file: Dockerfile
build-args: |
GRAALVM_VERSION=${{ env.LATEST_VERSION }}
JAVA_MAJOR_VERSION=${{ matrix.java_version }}
platforms: linux/amd64,linux/arm64/v8
tags: |
ghcr.io/${{ github.repository_owner }}/graalvm-oracle-jre:${{ env.LATEST_VERSION }}
push: true
provenance: false