-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
75 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
name: SpringBoot Gradle native Docker publish | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
java-version: | ||
description: "JDK version to use" | ||
required: true | ||
type: string | ||
docker-image: | ||
description: "Name of the docker image to push" | ||
required: true | ||
type: string | ||
docker-tag: | ||
description: "Tag of the docker image to push, defaults to current branch name" | ||
required: false | ||
type: string | ||
default: "" | ||
runs-on: | ||
description: "Runner to use" | ||
required: false | ||
type: string | ||
default: "ubuntu-latest" | ||
secrets: | ||
docker-repo: | ||
description: "Docker registry to push to" | ||
required: true | ||
docker-username: | ||
description: "Docker username" | ||
required: true | ||
docker-token: | ||
description: "Docker token" | ||
required: true | ||
|
||
jobs: | ||
publish: | ||
name: SpringBoot Native Gradle - Publish Docker | ||
runs-on: ["ubuntu-latest", "${{ inputs.runs-on }}"] | ||
concurrency: docker-${{ inputs.docker-tag }} | ||
steps: | ||
- name: Checkout source | ||
uses: actions/checkout@v4 | ||
- name: Login on registry | ||
uses: docker/login-action@v3.0.0 | ||
with: | ||
registry: ${{ secrets.docker-repo }} | ||
username: ${{ secrets.docker-username }} | ||
password: ${{ secrets.docker-token }} | ||
- name: Set up JDK | ||
uses: graalvm/setup-graalvm@v1 | ||
with: | ||
version: 'latest' | ||
java-version: ${{ inputs.java-version }} | ||
components: 'native-image' | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
native-image-job-reports: "true" | ||
|
||
- name: Calculate image tag | ||
id: image-tag | ||
run: | | ||
if [ -z "${{ inputs.docker-tag }}" ]; then | ||
echo "tag=${GITHUB_REF##*/}" >> "$GITHUB_OUTPUT" | ||
else | ||
echo "tag=${{ inputs.docker-tag }}" >> "$GITHUB_OUTPUT" | ||
fi | ||
- name: Boot build native | ||
uses: gradle/gradle-build-action@v2.8.0 | ||
with: | ||
cache-disabled: true | ||
arguments: | | ||
bootBuildImage | ||
--imageName=${{ secrets.docker-repo }}/${{ inputs.docker-image }}:${{ steps.image-tag.outputs.tag }} | ||
- name: Push on registry | ||
run: | | ||
docker push ${{ secrets.docker-repo }}/${{ inputs.docker-image }}:${{ steps.image-tag.outputs.tag }} |