Skip to content

Merge pull request #215 from adorsys/new-kc-cloud-config-2 #71

Merge pull request #215 from adorsys/new-kc-cloud-config-2

Merge pull request #215 from adorsys/new-kc-cloud-config-2 #71

name: Build and Push Image to GHCR
on:
workflow_dispatch:
push:
branches:
- main
- develop
tags:
- v*.*.*
env:
IMAGE_NAME: keycloak-ssi-deployment
REGISTRY: ghcr.io
jobs:
build-and-deploy:
runs-on: ubuntu-latest
# Skip this job if the pull request title or commit message in a merge commit
# contains 'image-updates' (used by ArgoCD Image Updater)
if: ${{ !contains(github.event.head_commit.message, 'image-updates') }}
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Set up Docker Buildx
id: builder
uses: docker/setup-buildx-action@v3
with:
install: true
driver: docker-container
driver-opts: image=moby/buildkit:latest
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}-${{ github.ref_name }}
restore-keys: |
${{ runner.os }}-buildx-${{ github.ref_name }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Metadata
uses: docker/metadata-action@v5
id: meta
with:
images: ${{ env.REGISTRY }}/${{ github.repository }}
tags: |
${{ github.ref == 'refs/heads/main' && 'latest' || '' }}
${{ startsWith(github.ref, 'refs/tags/v') && 'type=semver,pattern={{version}}' || '' }}
- name: Build Docker image and push to GHCR
id: push
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
builder: ${{ steps.builder.outputs.name }}
push: true
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache