Skip to content

clinic: add build job to the github workflow #26

clinic: add build job to the github workflow

clinic: add build job to the github workflow #26

Workflow file for this run

name: Clinic
on:
push:
branches:
- main
tags:
- "**"
paths-ignore:
- "**.md"
pull_request:
branches:
- main
env:
JDK_DISTRIBUTION: temurin
JAVA_VERSION: 21
NODE_VERSION: 21
jobs:
tests:
name: Tests
runs-on: ubuntu-latest
timeout-minutes: 10
services:
hapi-fhir:
image: hapiproject/hapi:latest
env:
server.port: 8090
hapi.fhir.tester.home.server_address: http://localhost:8090/fhir
hapi.fhir.allow_multiple_delete: true
ports:
- 8090:8090
defaults:
run:
working-directory: ./clinic
steps:
- name: Checkout Source
uses: actions/checkout@v4
- name: Setup JDK
uses: actions/setup-java@v3
with:
distribution: ${{ env.JDK_DISTRIBUTION }}
java-version: ${{ env.JAVA_VERSION }}
- name: Setup Lein Dependency Cache
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-lein-${{ hashFiles('clinic/project.clj') }}
# can't use `services.[id].options` to add Docker health checks because
# HAPI has a scratch docker image without a shell installation.
- name: HAPI FHIR Health Check
run: while ! curl -sSI "http://localhost:8090"; do sleep 5; done
- name: Run Tests
run: lein test
build:
name: Build
runs-on: ubuntu-latest
timeout-minutes: 10
if: github.event_name == 'push' # skip for pull requests.
needs:
- tests
permissions:
contents: read
packages: write
defaults:
run:
working-directory: ./clinic
steps:
- name: Checkout Source
uses: actions/checkout@v4
- name: Setup JDK
uses: actions/setup-java@v3
with:
distribution: ${{ env.JDK_DISTRIBUTION }}
java-version: ${{ env.JAVA_VERSION }}
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
cache: npm
cache-dependency-path: clinic/package-lock.json
- name: Setup Lein Dependency Cache
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-lein-${{ hashFiles('clinic/project.clj') }}
- name: Build CLJS
run: |
npm install
npx shadow-cljs release app
- name: Build Uberjar
run: lein uberjar
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Generate Docker Image Tags
id: docker-image-tags
run: |
image_name=ghcr.io/nilenso/ashutosh-onboarding/clinic
image_tags="${image_name}:latest"
if [[ "$GITHUB_REF" =~ refs/tags/* ]]; then
image_tags="${image_tags},${image_name}:${{ github.ref_name }}"
fi
echo "tags=$image_tags" >> "$GITHUB_OUTPUT"
- name: Build and Push Latest Docker Image
uses: docker/build-push-action@v5
with:
context: clinic
push: true
tags: ${{ steps.docker-image-tags.outputs.tags }}