Skip to content

Commit

Permalink
Merge branch 'master' into enhancement/local-dev-keycloak
Browse files Browse the repository at this point in the history
  • Loading branch information
sauljabin committed Feb 5, 2024
2 parents f4cd1d1 + 1e998ff commit 24fbf80
Show file tree
Hide file tree
Showing 423 changed files with 21,564 additions and 4,235 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Ignore everything
*
!canary/
!server/
!sdk-java/
!sdk-go/
Expand Down
101 changes: 101 additions & 0 deletions .github/actions/publish-image/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
name: Build and publish docker images
description: Builds and publish docker images to github registry
inputs:
image-name:
description: Image name for example lh-server
required: true
context:
description: Docker build context path
default: .
dockerfile:
description: Relative route of Dockerfile
required: true
registry:
description: Either github or ecr
default: github
github-token:
description: Github secret secrets.GITHUB_TOKEN required only if registry is github
default: ""
prefix:
description: prefix to be appended to image tag ex brach-
default: ""

runs:
using: composite
steps:
- name: Registry not recognized
shell: bash
if: ${{ inputs.registry != 'github' && inputs.registry != 'ecr' }}
run: |
echo "Registry not recognized, it should be github or ecr"
exit 1
- name: github-token is required
shell: bash
if: ${{ inputs.registry == 'github' && inputs.github-token == '' }}
run: |
echo "github-token is required when registry is github"
exit 1
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

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

- name: Log in to github registry
if: ${{ inputs.registry == 'github'}}
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ inputs.github-token }}

- name: Configure AWS credentials
if: ${{ inputs.registry == 'ecr' }}
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::637423582379:role/GithubActions-ECR
role-session-name: gha-ecr
aws-region: us-west-2

- name: Login to Amazon ECR
id: login-ecr
if: ${{ inputs.registry == 'ecr' }}
uses: aws-actions/amazon-ecr-login@v2

- name: Set DOCKER_IMAGE to github
if: ${{ inputs.registry == 'github'}}
shell: bash
run: |
echo DOCKER_IMAGE=ghcr.io/${{ github.repository }}/${{ inputs.image-name }} >> $GITHUB_ENV
- name: Set DOCKER_IMAGE to ecr
if: ${{ inputs.registry == 'ecr' }}
shell: bash
run: |
echo DOCKER_IMAGE=${{ steps.login-ecr.outputs.registry }}/${{ inputs.image-name }} >> $GITHUB_ENV
- name: Extract metadata (tags, labels) for Docker
uses: docker/metadata-action@v5
id: meta
with:
images: |
${{ env.DOCKER_IMAGE }}
flavor: |
prefix=${{ inputs.prefix }}
- name: Build and push Docker images
uses: docker/build-push-action@v5
with:
context: ${{ inputs.context }}
file: ${{ inputs.dockerfile }}
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

- name: Annotate image
shell: bash
run: |
echo "::notice title=Published Docker Image::${{ steps.meta.outputs.tags }}"
145 changes: 145 additions & 0 deletions .github/workflows/branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
name: branch
run-name: Publishing images for branch ${{ github.ref_name }}
on:
workflow_dispatch:
push:
branches-ignore:
- "master"
paths:
- .github/workflows/branch.yml
- docker/dashboard/**
- docker/server/**
- docker/standalone/**
- docker/canary/**
- server/**
- dashboard/**
- canary/**
permissions:
id-token: write
contents: read
jobs:
lh-server:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: "corretto"
java-version: 17

- name: Tests and Build
run: ./gradlew server:build

- uses: actions/upload-artifact@v4
with:
name: server-jar
path: server/build/libs/server-*-all.jar

- name: Build and Publish
uses: ./.github/actions/publish-image
with:
image-name: lh-server
dockerfile: docker/server/Dockerfile
registry: ecr
prefix: branch-

lh-canary:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: "corretto"
java-version: 17

- name: Tests and Build
run: ./gradlew canary:build

- uses: actions/upload-artifact@v4
with:
name: canary-jar
path: canary/build/libs/canary-*-all.jar

- name: Build and Publish
uses: ./.github/actions/publish-image
with:
image-name: lh-canary
dockerfile: docker/canary/Dockerfile
registry: ecr
prefix: branch-

lh-dashboard:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- uses: pnpm/action-setup@v2
with:
package_json_file: dashboard/package.json

- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 20
cache-dependency-path: dashboard/pnpm-lock.yaml
cache: pnpm

- name: Build Dashboard
working-directory: ./dashboard
run: |
pnpm install
pnpm build
- name: Build and Publish
uses: ./.github/actions/publish-image
with:
image-name: lh-dashboard
dockerfile: docker/dashboard/Dockerfile
registry: ecr
prefix: branch-

lh-standalone:
runs-on: ubuntu-latest
needs:
- lh-server
steps:
- name: Checkout
uses: actions/checkout@v3

- uses: pnpm/action-setup@v2
with:
package_json_file: ./dashboard/package.json

- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 20
cache-dependency-path: dashboard/pnpm-lock.yaml
cache: pnpm

- name: Build Dashboard
working-directory: ./dashboard
run: |
pnpm install
pnpm build
- name: Dowload Server Jar artifact
uses: actions/download-artifact@v4
with:
name: server-jar
path: server/build/libs/

- name: Build and Publish
uses: ./.github/actions/publish-image
with:
image-name: lh-standalone
dockerfile: docker/standalone/Dockerfile
registry: ecr
prefix: branch-
13 changes: 13 additions & 0 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: master
run-name: Merge on master branch
on:
workflow_dispatch:
push:
branches:
- master
permissions:
packages: write
contents: read
jobs:
publish-docker:
uses: ./.github/workflows/publish-docker.yml
Loading

0 comments on commit 24fbf80

Please sign in to comment.