Skip to content

Commit

Permalink
Add github action to build and upload theme Docker images.
Browse files Browse the repository at this point in the history
  • Loading branch information
ewelinagr committed May 13, 2024
1 parent 268471f commit e7c1788
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
69 changes: 69 additions & 0 deletions .github/workflows/build_and_upload_theme_on_push_to_dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Jobs to build and deploy a Docker image for Fairspace Keycloak theme on push to the dev or release branches

name: Build & Upload Fairspace Keycloak Theme Docker image

env:
DOCKER_REGISTRY: ghcr.io

on:
push:
branches:
- dev
- release

jobs:
# A job to generate one shared unique version tag per build cycle for all built artifacts
generate-version:
runs-on: ubuntu-latest
outputs:
output1: ${{ steps.version.outputs.keycloak_fairspace_theme_version }}
steps:
- name: Check out repository
uses: actions/checkout@v4

- id: version
name: Generating version tag for artifacts
run: |
# EXTRACT VERSION
BRANCH=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}
echo "Building theme image from the branch: $BRANCH"
VER=$(cat ./themes/VERSION)
echo "Building theme image of version: $VER"
# DOCKER TAG TO BE ATTACHED (SHARED WITHIN OUTPUT):
if [ $BRANCH != "release" ]
then
VER=$VER-SNAPSHOT
fi
echo "keycloak_fairspace_theme_version=$VER" >> "$GITHUB_OUTPUT"
echo "Docker tag to be attached to images: $VER"
build-and-upload-docker-image-for-keycloak-fairspace-theme:
needs: [generate-version]
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4

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

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.DOCKER_REGISTRY }}/${{ github.repository }}/keycloak-fairspace-theme

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: ./themes/
push: true
tags: ${{ env.DOCKER_REGISTRY }}/${{ github.repository }}/keycloak-fairspace-theme:${{needs.generate-version.outputs.output1}}
labels: ${{ steps.meta.outputs.labels }}
1 change: 1 addition & 0 deletions themes/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.0.1

0 comments on commit e7c1788

Please sign in to comment.