Skip to content
Merged
Show file tree
Hide file tree
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
78 changes: 78 additions & 0 deletions .github/workflows/registry-build-publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Build and publish to Github Container Registry

on:
push:
branches: [main]
tags: ['v*.*.*']
pull_request:
branches:
- main
workflow_dispatch:

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

jobs:
build-and-push-images:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
pull-requests: write # Add permission to write to pull requests

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

- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3

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

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
flavor: |
latest=auto
prefix=
suffix=

- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
push: true
platforms: linux/amd64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Find Comment
if: github.event_name == 'pull_request'
uses: peter-evans/find-comment@v3
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: The Docker image was built successfully with the following name

- name: Comment on pull request
if: github.event_name == 'pull_request'
uses: peter-evans/create-or-update-comment@v4
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
edit-mode: replace
body: |
The Docker image was built successfully with the following name:
```
${{ steps.meta.outputs.tags }}
```
19 changes: 19 additions & 0 deletions .github/workflows/registry-pr-purge.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Purge Pull Request Image

# https://docs.github.com/en/actions/reference/events-that-trigger-workflows#registry_package
# Purge Pull Request Image
on:
pull_request:
types: [closed]

jobs:
purge_pr_image:
runs-on: ubuntu-latest
steps:
- name: Purge Pull Request Image
uses: vlaurin/action-ghcr-prune@v0.6.0
with:
token: ${{ secrets.GHCR_TOKEN}}
organization: ${{ github.repository_owner}}
container: ${{ github.event.repository.name }}
tag-regex: pr-${{github.event.pull_request.number}}$
18 changes: 18 additions & 0 deletions .github/workflows/registry-purge.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# https://docs.github.com/en/actions/reference/events-that-trigger-workflows#registry_package
# Run cleanup job if a new package was published or updated
name: Purge untagged images

on:
registry_package:

jobs:
purge_untagged_images:
runs-on: ubuntu-latest
steps:
- name: clean packages
uses: vlaurin/action-ghcr-prune@v0.6.0
with:
token: ${{ secrets.GHCR_TOKEN }}
organization: ${{ github.repository_owner }}
container: ${{ github.event.repository.name }}
untagged: true
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Stage 1: Download the theme
FROM alpine:latest AS loader
RUN apk add --no-cache curl
RUN curl -L -o /kc-foodmission-theme.jar \
"https://github.com/reedu-reengineering-education/foodmission-keycloak/releases/latest/download/keycloak-theme-for-kc-all-other-versions.jar"

# Stage 2: Final Keycloak image
FROM quay.io/keycloak/keycloak:26.3
COPY --from=loader /kc-foodmission-theme.jar /opt/keycloak/providers/
# Keycloak images usually handle permissions for the providers folder automatically,
# but you can add this if needed:
USER root
RUN chown 1000:0 /opt/keycloak/providers/kc-foodmission-theme.jar
USER 1000
Loading