Skip to content

[Analyze-709] clone concept-sets to an app #3826

[Analyze-709] clone concept-sets to an app

[Analyze-709] clone concept-sets to an app #3826

name: d2e Docker Build
on:
pull_request:
types:
- opened
- ready_for_review
- reopened
- synchronize
merge_group:
push:
branches:
- develop
workflow_dispatch:
inputs:
GIT_REPO_FULL_NAME:
description: Select RepoName
required: false
type: choice
options:
- ohdsi/d2e
- data2evidence/d2e
GIT_BRANCH_NAME:
default: develop
description: Enter BranchName / ReleaseTagName
required: true
type: string
tag:
description: Enter Tag name for docker image
required: true
type: string
concurrency:
group: ${{ github.event.inputs.GIT_BRANCH_NAME || github.head_ref || github.ref_name }}-${{ github.event_name }}-docker-build-push
cancel-in-progress: true
env:
GIT_BRANCH_NAME: ${{ github.event.inputs.GIT_BRANCH_NAME || github.head_ref || github.ref_name }} # workflow_dispatch || pull_request || push
GIT_REPO_FULL_NAME: ${{ github.event.inputs.GIT_REPO_FULL_NAME || github.event.pull_request.head.repo.full_name || github.event.repository.full_name }} # workflow_dispatch || pull_request || push
jobs:
check_file_changes:
environment: "github" # ${{github.event_name == 'workflow_dispatch' && contains('release', github.ref_name) && 'dockerhub' || 'github'}}
runs-on: ubuntu-latest
if: (github.ref_name == 'develop' || contains('release/', github.ref_name) || github.event_name == 'workflow_dispatch') || ( github.event_name == 'pull_request' && !github.event.pull_request.draft ) # Should run if branch is develop/release/workflow_dispatch and doesnt have a PR
outputs:
changes: ${{ steps.file_changes.outputs.src }}
rkernel: ${{ steps.file_changes.outputs.rkernel }}
jenv: ${{ job.environment }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: file_changes
with:
initial-fetch-depth: 1
filters: |
src:
- "flows/**"
- "services/**"
- "package.json"
- "docker-compose.yml"
rkernel:
- "./services/enterprise-gateway/r-strategus-lib/**"
- "./flows/_shared_flow_utils/postgresql-42.3.1.jar"
- ".github/workflows/docker-build-push.yaml"
bld:
needs: [check_file_changes]
if: (github.ref_name == 'develop' || contains('release', github.ref_name) || github.event_name == 'workflow_dispatch') || ( github.event_name == 'pull_request' && !github.event.pull_request.draft && (needs.check_file_changes.outputs.changes == 'true' || needs.check_file_changes.outputs.rkernel == 'true') ) # Should run if branch is develop/release/workflow_dispatch and doesnt have a PR
runs-on: ubuntu-latest
env:
DOCKER_BUILD_DISABLE: ${{ vars.DOCKER_BUILD_DISABLE || 'false' }}
DOCKER_BUILD_PUSH_BOOL_OVERRIDE: ${{ vars.DOCKER_BUILD_PUSH_BOOL_OVERRIDE || 'false' }}
GIT_BRANCH_NAME: ${{ github.event.inputs.GIT_BRANCH_NAME || github.head_ref || github.ref_name }} # workflow_dispatch || pull_request || push
GIT_REPO_FULL_NAME: ${{ github.event.inputs.GIT_REPO_FULL_NAME || github.event.pull_request.head.repo.full_name || github.event.repository.full_name }} # workflow_dispatch || pull_request || push
DOCKER_BUILD_ARG1: GITHUB_PAT=${{ secrets.GITHUB_TOKEN }}
REG_URL: ${{ needs.check_file_changes.outputs.jenv == 'dockerhub' && 'registry.hub.docker.com/data2evidence' || 'ghcr.io/ohdsi'}}
strategy:
fail-fast: false
matrix:
include:
- AZ_REG_REPOSITORY: d2e/flow-base
DOCKER_BUILD_CONTEXT_PATH: ./flows
DOCKER_BUILD_FILE_PATH: ./flows/base/Dockerfile
- AZ_REG_REPOSITORY: d2e/flow-cohort-survival
DOCKER_BUILD_CONTEXT_PATH: ./flows
DOCKER_BUILD_FILE_PATH: ./flows/cohort_survival/Dockerfile
- AZ_REG_REPOSITORY: d2e/flow-i2b2
DOCKER_BUILD_CONTEXT_PATH: ./flows
DOCKER_BUILD_FILE_PATH: ./flows/i2b2/Dockerfile
- AZ_REG_REPOSITORY: d2e/flow-search-embedding
DOCKER_BUILD_CONTEXT_PATH: ./flows
DOCKER_BUILD_FILE_PATH: ./flows/search_embedding/Dockerfile
- AZ_REG_REPOSITORY: d2e/flow-data-management
DOCKER_BUILD_CONTEXT_PATH: ./flows
DOCKER_BUILD_FILE_PATH: ./flows/data_management/Dockerfile
- AZ_REG_REPOSITORY: d2e/flow-loyalty-score
DOCKER_BUILD_CONTEXT_PATH: ./flows
DOCKER_BUILD_FILE_PATH: ./flows/loyalty_score/Dockerfile
- AZ_REG_REPOSITORY: d2e/flow-hades
DOCKER_BUILD_CONTEXT_PATH: ./flows
DOCKER_BUILD_FILE_PATH: ./flows/hades/Dockerfile
- AZ_REG_REPOSITORY: d2e/flow-data-transformation
DOCKER_BUILD_CONTEXT_PATH: ./flows
DOCKER_BUILD_FILE_PATH: ./flows/data_transformation/Dockerfile
- AZ_REG_REPOSITORY: d2e-pg-mgmt-init
DOCKER_BUILD_FILE_PATH: ./services/alp-pg-management/Dockerfile
DOCKER_BUILD_CONTEXT_PATH: ./services/alp-pg-management
- AZ_REG_REPOSITORY: d2e-logto
DOCKER_BUILD_FILE_PATH: ./services/alp-logto/Dockerfile
DOCKER_BUILD_CONTEXT_PATH: ./services/alp-logto
- AZ_REG_REPOSITORY: d2e-logto-post-init
DOCKER_BUILD_FILE_PATH: ./services/alp-logto/post-init/Dockerfile
DOCKER_BUILD_CONTEXT_PATH: ./services/alp-logto/post-init
- AZ_REG_REPOSITORY: d2e-fhir-server
DOCKER_BUILD_FILE_PATH: ./services/alp-fhir/Dockerfile
DOCKER_BUILD_CONTEXT_PATH: ./services/alp-fhir
- AZ_REG_REPOSITORY: d2e-fhir-fe-server
DOCKER_BUILD_FILE_PATH: ./services/alp-fhir/Dockerfile.frontend
DOCKER_BUILD_CONTEXT_PATH: ./services/alp-fhir
- AZ_REG_REPOSITORY: d2e-cachedb
DOCKER_BUILD_FILE_PATH: ./services/cachedb/Dockerfile
DOCKER_BUILD_CONTEXT_PATH: .
- AZ_REG_REPOSITORY: d2e-enterprise-gateway
DOCKER_BUILD_FILE_PATH: ./services/enterprise-gateway/Dockerfile
DOCKER_BUILD_CONTEXT_PATH: ./services/enterprise-gateway
- AZ_REG_REPOSITORY: d2e-r-ohdsi-kernel
DOCKER_BUILD_FILE_PATH: ./services/enterprise-gateway/kernels/R_ohdsi_docker/Dockerfile
DOCKER_BUILD_CONTEXT_PATH: .
build_disable: ${{ (needs.check_file_changes.outputs.rkernel != 'true') && 'true' || 'false' }}
- AZ_REG_REPOSITORY: d2e-trex
DOCKER_BUILD_FILE_PATH: ./services/trex/Dockerfile
DOCKER_BUILD_CONTEXT_PATH: .
steps:
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
# this might remove tools that are actually needed,
# if set to "true" but frees about 6 GB
tool-cache: false
# all of these default to true, but feel free to set to
# "false" if necessary for your workflow
android: true
dotnet: true
haskell: true
large-packages: false
docker-images: true
swap-storage: true
- name: Check out repository code
uses: actions/checkout@v4
with:
ref: ${{ env.GIT_BRANCH_NAME }}
repository: ${{ env.GIT_REPO_FULL_NAME }}
submodules: recursive
- name: Setting up variables
id: setup
env:
DOCKER_BUILD_PUSH_BOOL_OVERRIDE: ${{ vars.DOCKER_BUILD_PUSH_BOOL_OVERRIDE || false }}
run: |
DOCKER_BUILD_PUSH_BOOL_STR=false
if [[ $GITHUB_EVENT_NAME == "push" ]] || [ $GITHUB_EVENT_NAME = "workflow_dispatch" ] || [ $DOCKER_BUILD_PUSH_BOOL_OVERRIDE = true]; then
DOCKER_BUILD_PUSH_BOOL_STR=true
fi
if [[ ${{ github.event_name }} == "workflow_dispatch" ]]; then
DOCKER_IMG_TAG_NAME=${{ github.event.inputs.tag }}
elif [[ ${{ github.event_name }} == "push" ]]; then
DOCKER_IMG_TAG_NAME=develop
else
DOCKER_IMG_TAG_NAME=$(echo $(git rev-parse --short HEAD))
fi
echo DOCKER_BUILD_PUSH_BOOL_STR=$DOCKER_BUILD_PUSH_BOOL_STR | tee -a $GITHUB_ENV | tee -a $GITHUB_OUTPUT | tee -a $GITHUB_STEP_SUMMARY
echo DOCKER_IMG_TAG_NAME=$DOCKER_IMG_TAG_NAME | tee -a $GITHUB_ENV | tee -a $GITHUB_OUTPUT | tee -a $GITHUB_STEP_SUMMARY
echo GIT_BRANCH_NAME="${GIT_BRANCH_NAME}" | tee -a $GITHUB_ENV | tee -a $GITHUB_OUTPUT | tee -a $GITHUB_STEP_SUMMARY
echo GIT_REPO_FULL_NAME="${GIT_REPO_FULL_NAME}" | tee -a $GITHUB_OUTPUT | tee -a $GITHUB_STEP_SUMMARY
echo AZ_REG_REPOSITORY=${{ matrix.AZ_REG_REPOSITORY }} | tee -a $GITHUB_ENV | tee -a $GITHUB_OUTPUT | tee -a $GITHUB_STEP_SUMMARY
echo DOCKER_BUILD_CONTEXT_PATH=${{ matrix.DOCKER_BUILD_CONTEXT_PATH }} | tee -a $GITHUB_ENV | tee -a $GITHUB_OUTPUT | tee -a $GITHUB_STEP_SUMMARY
echo DOCKER_BUILD_FILE_PATH=${{ matrix.DOCKER_BUILD_FILE_PATH }} | tee -a $GITHUB_ENV | tee -a $GITHUB_OUTPUT | tee -a $GITHUB_STEP_SUMMARY
echo GITHUB_SHA=$GITHUB_SHA | tee -a $GITHUB_STEP_SUMMARY
echo GITHUB_SHA_SHORT=$GITHUB_SHA_SHORT | tee -a $GITHUB_ENV | tee -a $GITHUB_OUTPUT | tee -a $GITHUB_STEP_SUMMARY
- name: "Login to GitHub Container Registry"
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{github.actor}}
password: ${{secrets.GITHUB_TOKEN}}
- name: "Login to Docker Container Registry"
uses: docker/login-action@v3
if: ${{ needs.check_file_changes.outputs.jenv == 'dockerhub' }}
with:
registry: registry.hub.docker.com
username: data2evidence
password: ${{secrets.DOCKER_TOKEN}}
- uses: docker/setup-buildx-action@v3
id: builder
- name: Build and Push
id: build-push
if: ${{matrix.build_disable != 'true' || github.event_name == 'workflow_dispatch' || github.ref_name == 'develop' || contains('release', github.ref_name) }}
uses: docker/build-push-action@v6
with:
builder: ${{ steps.builder.outputs.name }}
context: ${{ env.DOCKER_BUILD_CONTEXT_PATH }}
file: ${{ env.DOCKER_BUILD_FILE_PATH }}
platforms: "linux/amd64"
push: ${{ env.DOCKER_BUILD_PUSH_BOOL_STR == 'true' }}
pull: ${{ matrix.pull_base == 'true' || false }}
tags: ${{ env.REG_URL }}/${{ env.AZ_REG_REPOSITORY }}:${{ env.DOCKER_IMG_TAG_NAME }}
provenance: false
build-args: |
GIT_COMMIT_ARG=${{ github.sha }}
BUILD_TYPE=OSS
${{ env.DOCKER_BUILD_ARG1 }}
- name: delete-untagged-images
uses: actions/delete-package-versions@v5
if: env.GIT_BRANCH_NAME == 'develop'
continue-on-error: true
with:
package-name: ${{ env.AZ_REG_REPOSITORY }}
package-type: "container"
min-versions-to-keep: 3
delete-only-untagged-versions: "true"
docker-success:
needs: bld
runs-on: ubuntu-latest
steps:
- name: Check
run: echo "Check"