Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Build and Push Docker Images

on:
push:
branches: [ main ]
release:
types: [ published ]

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'

- name: Build with Maven
run: mvn clean package -DskipTests

- name: Copy JAR to docker directory
run: |
rm -fv docker/plugins/*.jar
mkdir -p docker/plugins/
cp -pv ./target/keycloak-facilities-admin-plugin-*.jar docker/plugins/

- name: Extract Keycloak version from pom.xml
id: version
run: |
VERSION=$(grep -oP '(?<=<keycloak.version>)[^<]+' pom.xml)
echo "keycloak_version=$VERSION" >> $GITHUB_OUTPUT

- name: Log in to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: ./docker
push: true
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }}
build-args: |
KEYCLOAK_IMAGE=quay.io/keycloak/keycloak:${{ steps.version.outputs.keycloak_version }}
labels: ${{ steps.meta.outputs.labels }}
Loading