-
Notifications
You must be signed in to change notification settings - Fork 0
76 lines (66 loc) · 2.68 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
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]
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