Skip to content

ci: Print Maven version #8

ci: Print Maven version

ci: Print Maven version #8

name: Build & Publish Docker Image to GHCR
on:
push:
branches:
- main # Change if needed
workflow_dispatch: # Allow manual trigger
permissions:
contents: read
packages: write # Allows pushing to GHCR
jobs:
build-jar:
name: Build JAR with Maven
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
cache: 'maven'
- name: Build with Maven
run: mvn clean package -DskipTests -ntp -V
- name: Upload JAR as Artifact
uses: actions/upload-artifact@v4
with:
name: java-artifacts
path: |
target/*.jar
target/lib/*.jar
build-and-push:
name: Build & Push Docker Image
runs-on: ubuntu-latest
needs: build-jar
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Download JAR Artifact
uses: actions/download-artifact@v4
with:
name: java-artifacts # Must match the upload name
path: target/ # Download location inside the runner
- name: Build Docker Image
run: |
docker build -t ghcr.io/${{ github.repository }}:latest .
- name: Push Docker Image to GHCR
run: |
docker push ghcr.io/${{ github.repository }}:latest