build(lab-server): add realm export #590
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Lab Server | |
on: | |
push: | |
paths: | |
- '.github/workflows/lab-server.yml' | |
- 'yarn.lock' | |
- 'lab-server/**' | |
defaults: | |
run: | |
working-directory: ./lab-server | |
env: | |
PORT: 8081 | |
KEYCLOAK_AUTH_SERVER_URL: ${{ secrets.KEYCLOAK_AUTH_SERVER_URL }} | |
KEYCLOAK_REALM: ${{ secrets.KEYCLOAK_REALM }} | |
KEYCLOAK_CLIENT_ID: ${{ secrets.KEYCLOAK_CLIENT_ID }} | |
KEYCLOAK_SECRET: ${{ secrets.KEYCLOAK_SECRET }} | |
DB_HOST: postgres | |
DB_PORT: 5432 | |
DB_USER: postgres | |
DB_PASS: postgres | |
DB_NAME: lab_server_db | |
MINIO_PORT: 9000 | |
MINIO_ENDPOINT: minio | |
MINIO_ROOT_USER: admin_minio | |
MINIO_ROOT_PASSWORD: admin_minio | |
jobs: | |
lint: | |
name: Lint | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- run: yarn | |
- run: yarn lint | |
test-e2e: | |
name: Test E2E | |
runs-on: ubuntu-latest | |
container: | |
image: node:18-buster-slim | |
services: | |
minio: | |
# we refrain from using the official minio image as we would need to | |
# pass an additional `server` sub-command to the container. Currently, | |
# GH-actions does not support this. Note that this is not an official | |
# minio image and should therefore not be used in production | |
# environments. See: https://stackoverflow.com/questions/60849745/ | |
image: bitnami/minio | |
postgres: | |
image: postgres | |
env: | |
POSTGRES_USER: ${{ env.DB_USER }} | |
POSTGRES_PASSWORD: ${{ env.DB_PASS }} | |
POSTGRES_DB: ${{ env.DB_NAME }} | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
steps: | |
- uses: actions/checkout@v2 | |
- run: yarn | |
- run: cp test/helpers/e2e-users.json src/seeder/users.json | |
- run: yarn seed:run | |
- run: yarn test:e2e:cov | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: coverage-report | |
path: lab-server/coverage | |
codecov: | |
name: Generate Code Coverage Report | |
needs: [test-e2e] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions/download-artifact@v3 | |
with: | |
name: coverage-report | |
path: lab-server/coverage | |
- uses: codecov/codecov-action@v2 | |
with: | |
flags: lab-server | |
directory: lab-server/coverage | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- run: yarn | |
- run: yarn build | |
build-and-push-image: | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
needs: [lint, test-e2e, build] | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }}-lab-server | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Create empty .env file (expected by Dockerfile) | |
run: cp .env.example .env | |
- name: Log in to the Container registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v3 | |
with: | |
context: . | |
file: ./lab-server/Dockerfile | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |