Skip to content

alicia-koh/data-1630 #4438

alicia-koh/data-1630

alicia-koh/data-1630 #4438

Workflow file for this run

name: Docker Build
run-name: ${{ github.event.inputs.GIT_BRANCH_NAME || github.head_ref || github.ref_name }}
on:
pull_request:
types:
- opened
- ready_for_review
- reopened
- synchronize
push:
branches:
- develop
workflow_dispatch:
inputs:
GIT_REPO_FULL_NAME:
description: Select RepoName
required: false
type: choice
options:
- data2evidence/d2e
GIT_BRANCH_NAME:
default: develop
description: Enter BranchName / ReleaseTagName
required: true
type: string
DOCKER_IMAGE_TAG_NAME:
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-prune
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:
setup:
runs-on: ubuntu-latest
steps:
- name: setup
id: setup
env:
DOCKER_BUILD_PUSH_BOOL_OVERRIDE: ${{ vars.DOCKER_BUILD_PUSH_BOOL_OVERRIDE || false }}
run: |
DOCKER_BUILD_PUSH_BOOL_STR=true
if [ $GIT_BRANCH_NAME == "develop" ]; then
DOCKER_IMG_TAG_NAME=develop
elif [ $GITHUB_EVENT_NAME = "workflow_dispatch" ]; then
DOCKER_IMG_TAG_NAME=${{ github.event.inputs.DOCKER_IMAGE_TAG_NAME }}
elif [ $DOCKER_BUILD_PUSH_BOOL_OVERRIDE = true ]; then
DOCKER_IMG_TAG_NAME=$GIT_BRANCH_NAME
if [[ $GIT_BRANCH_NAME = */* ]]; then
DOCKER_IMG_TAG_NAME=$(printf "%s" "$GIT_BRANCH_NAME" | awk -F '/' '{print $2}')
fi
else
DOCKER_BUILD_PUSH_BOOL_STR=false
DOCKER_IMG_TAG_NAME=$(echo ${{ github.sha }} | cut -c1-8)
fi
echo DOCKER_BUILD_PUSH_BOOL_STR=$DOCKER_BUILD_PUSH_BOOL_STR | tee -a $GITHUB_OUTPUT | tee -a $GITHUB_STEP_SUMMARY
echo DOCKER_IMG_TAG_NAME=$DOCKER_IMG_TAG_NAME | tee -a $GITHUB_OUTPUT | tee -a $GITHUB_STEP_SUMMARY
echo GIT_BRANCH_NAME="${GIT_BRANCH_NAME}" | 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
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: |
echo HOSTNAME=$HOSTNAME
echo "$GITHUB_CONTEXT"
outputs:
DOCKER_BUILD_PUSH_BOOL_STR: ${{ steps.setup.outputs.DOCKER_BUILD_PUSH_BOOL_STR }}
DOCKER_IMG_TAG_NAME: ${{ steps.setup.outputs.DOCKER_IMG_TAG_NAME }}
GIT_BRANCH_NAME: ${{ steps.setup.outputs.GIT_BRANCH_NAME }}
GIT_REPO_FULL_NAME: ${{ steps.setup.outputs.GIT_REPO_FULL_NAME }}
bld:
needs: setup
if: vars.DOCKER_BUILD_FORCE == 'true' || needs.setup.outputs.GIT_BRANCH_NAME == 'develop' || contains('release', needs.setup.outputs.GIT_BRANCH_NAME) || github.event_name == 'workflow_dispatch' || ( github.event_name == 'pull_request' && !github.event.pull_request.draft ) # run if branch is develop|release|workflow_dispatch OR any non-draft pull_request
strategy:
fail-fast: false
matrix:
include:
- name: d2e-pg-mgmt-init
directory: ./services/alp-pg-management
context: ./services/alp-pg-management
fileName: Dockerfile
- name: d2e-logto
directory: ./services/alp-logto
context: ./services/alp-logto
fileName: Dockerfile
- name: d2e-logto-post-init
directory: ./services/alp-logto/post-init
context: ./services/alp-logto/post-init
fileName: Dockerfile
- name: d2e-fhir-server
directory: ./services/alp-fhir
context: ./services/alp-fhir
fileName: Dockerfile
- name: d2e-fhir-fe-server
directory: ./services/alp-fhir
context: ./services/alp-fhir
fileName: Dockerfile.frontend
- name: d2e-cachedb
directory: ./services/cachedb
context: .
fileName: Dockerfile
uses: ./.github/workflows/docker-push-called.yml
with:
AZ_REG_REPOSITORY: ${{ matrix.name }}
DOCKER_BUILD_CONTEXT_PATH: ${{ matrix.context }}
DOCKER_BUILD_FILE_PATH: ${{ matrix.directory }}/${{ matrix.fileName }}
DOCKER_BUILD_PUSH_BOOL_STR: ${{ needs.setup.outputs.DOCKER_BUILD_PUSH_BOOL_STR }}
DOCKER_IMG_TAG_NAME: ${{ needs.setup.outputs.DOCKER_IMG_TAG_NAME }}
GIT_BRANCH_NAME: ${{ needs.setup.outputs.GIT_BRANCH_NAME }}
GIT_REPO_FULL_NAME: ${{ needs.setup.outputs.GIT_REPO_FULL_NAME }}
secrets: inherit