Skip to content

Docker Nightly

Docker Nightly #257

name: Docker Nightly
on:
# This can be used to automatically publish nightlies at UTC nighttime
schedule:
- cron: "0 0 * * *" # run at midnight UTC
# This can be used to allow manually triggering nightlies from the web interface
workflow_dispatch:
jobs:
check-build:
runs-on: ubuntu-latest
name: Check latest build
outputs:
last-build-sha: ${{ fromJson(steps.check-last-build.outputs.data).workflow_runs[0].head_sha }}
steps:
- uses: octokit/[email protected]
id: check-last-build
with:
route: GET /repos/${{github.repository}}/actions/workflows/docker-nightly.yml/runs?per_page=1&status=completed
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: "echo Last daily build: ${{ fromJson(steps.check-last-build.outputs.data).workflow_runs[0].head_sha }}"
check-secrets:
runs-on: ubuntu-latest
name: Check secrets
outputs:
defined: ${{ steps.check-dockerhub-secrets.outputs.defined }}
steps:
- id: check-dockerhub-secrets
shell: bash
run: |
if [[ "${{ secrets.DOCKERHUB_USERNAME }}" != '' && "${{ secrets.DOCKERHUB_TOKEN }}" ]]; then
echo "defined=true" >> $GITHUB_OUTPUT;
else
echo "defined=false" >> $GITHUB_OUTPUT;
fi
build-publish:
if: needs.check-build.outputs.last-build-sha != github.sha && needs.check-secrets.outputs.defined == 'true'
runs-on: ubuntu-latest
name: Build and push Docker image
needs: [check-build, check-secrets]
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Install Java 21
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
- name: Build with Maven
run: ./mvnw clean package -Pproduction -e
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- id: lowercase-repo
name: Lowercase repository name
run: |
echo "repository=${GITHUB_REPOSITORY@L}" >> $GITHUB_OUTPUT
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.lowercase-repo.outputs.repository }}:nightly
platforms: linux/amd64,linux/arm64
- name: Docker Hub Description
uses: peter-evans/dockerhub-description@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
repository: ${{ steps.lowercase-repo.outputs.repository }}