This commit is contained in:
leehk 2025-04-16 14:42:11 +08:00
parent ab01c1c2cc
commit f1cc825845
3 changed files with 12 additions and 13 deletions

View File

@ -14,11 +14,6 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
# Global environment variables accessible in the calling job
env:
PROJECT_NAME: aimingmed-ai
REPO: https://github.com/aimingmed # Updated repo for aimingmed-ai
jobs:
# This job defines the matrix and calls the reusable workflow for each image build
build:
@ -45,6 +40,9 @@ jobs:
- IMAGE_NAME: frontend-aimingmedai
BUILD_CONTEXT: ./app/frontend
DOCKERFILE: ./app/frontend/Dockerfile.test
- IMAGE_NAME: tests-aimingmedai
BUILD_CONTEXT: ./app/tests
DOCKERFILE: ./app/tests/Dockerfile
# Call the reusable workflow
uses: ./.github/workflows/template_build.yml # Path to the reusable workflow file
@ -52,7 +50,7 @@ jobs:
with:
# Pass values from the matrix context and global env
project_name: aimingmed-ai
repo: https://github.com/aimingmed
image_repo: ghcr.io/$(echo $GITHUB_REPOSITORY | tr '[A-Z]' '[a-z]')/
image_name: ${{ matrix.image_config.IMAGE_NAME }}
build_context: ${{ matrix.image_config.BUILD_CONTEXT }}
dockerfile: ${{ matrix.image_config.DOCKERFILE }}
@ -68,7 +66,7 @@ jobs:
uses: ./.github/workflows/template_test.yml # Path to the reusable workflow file
with:
projectName: aimingmed-ai
repo: https://github.com/aimingmed
image_repo: ghcr.io/$(echo $GITHUB_REPOSITORY | tr '[A-Z]' '[a-z]')/
# Pass test environment variables as JSON string
testEnvs: >
[

View File

@ -10,7 +10,7 @@ on:
project_name:
required: true
type: string
repo:
image_repo:
required: true
type: string
image_name:
@ -72,7 +72,7 @@ jobs:
# Define tags consistently using inputs
id: tags
run: |
echo "image_repo_path=ghcr.io/$(echo $GITHUB_REPOSITORY | tr '[A-Z]' '[a-z]')/${{ inputs.image_name }}" >> $GITHUB_OUTPUT
echo "image_repo_path=${{ inputs.image_repo }}/${{ inputs.image_name }}" >> $GITHUB_OUTPUT
echo "tag_build_id=${{ inputs.build_id }}" >> $GITHUB_OUTPUT
echo "tag_commit_sha=${{ inputs.commit_sha }}" >> $GITHUB_OUTPUT

View File

@ -6,7 +6,7 @@ on:
projectName:
required: true
type: string
repo:
image_repo:
required: true
type: string
images: # JSON string defining services for compose
@ -43,7 +43,7 @@ jobs:
runs-on: ubuntu-latest
env:
# Env vars needed for compose file generation/execution
REPO: ${{ inputs.repo }}
IMAGE_REPO: ${{ inputs.image_repo }}
PROJECT_NAME: ${{ inputs.projectName }}
TAG: ${{ github.run_id }} # Use run_id as the build tag
@ -85,7 +85,8 @@ jobs:
foreach ($img in $images) {
$serviceName = $img.name
$svc = @{}
$svc.image = "${{ env.REPO }}/${{ env.PROJECT_NAME }}/$($serviceName):${{ env.TAG }}" # Use run_id tag
$svc.image = "${{ env.IMAGE_REPO }}/$($serviceName):${{ env.TAG }}" # Use run_id tag
if ($img.depends_on) {
$svc.depends_on = $img.depends_on
}
@ -164,7 +165,7 @@ jobs:
$ENV_ARGS \
-v "$STAGING_DIR:$RESULTS_PATH" \
--rm \
"${{ inputs.repo }}/${{ inputs.projectName }}/${{ inputs.testContainerName }}:${{ github.run_id }}" \
"${{ env.IMAGE_REPO }}/$($serviceName)/${{ inputs.testContainerName }}:${{ github.run_id }}" \
"$test_dir"
# Add error handling if needed (e.g., exit script if a test run fails)
if [ $? -ne 0 ]; then