fix(ci): Fix workflow job dependencies and execution flow

- Removed runtime-base from build job dependencies (build now only depends on changes)
- runtime-base now only runs when needed (if needs_runtime_build or needs_build is true)
- build job now handles missing runtime-base outputs gracefully
- deploy-staging and deploy-production now only depend on build (not runtime-base)
- Added always() conditions to ensure jobs run even if previous jobs are skipped
- Fixes issue where workflow stopped after runtime-base job when build was skipped
This commit is contained in:
2025-11-01 21:21:58 +01:00
parent 13e12487d7
commit 0c7b96e887

View File

@@ -187,6 +187,7 @@ jobs:
runtime-base:
name: Build Runtime Base Image
needs: changes
if: always()
runs-on: docker-build
outputs:
image_ref: ${{ steps.set-result.outputs.image_ref }}
@@ -470,7 +471,7 @@ jobs:
# Job 2: Build & Push Docker Image
build:
name: Build Docker Image
needs: [changes, runtime-base]
needs: [changes]
if: needs.changes.outputs.needs_build == 'true'
runs-on: docker-build
outputs:
@@ -647,8 +648,9 @@ jobs:
DEFAULT_IMAGE="${{ env.REGISTRY }}/${{ env.RUNTIME_IMAGE_NAME }}:latest"
SELECTED_IMAGE="$DEFAULT_IMAGE"
if [ -n "${{ needs.runtime-base.outputs.image_ref }}" ]; then
SELECTED_IMAGE="${{ needs.runtime-base.outputs.image_ref }}"
RUNTIME_BASE_REF="${{ needs.runtime-base.outputs.image_ref || '' }}"
if [ -n "$RUNTIME_BASE_REF" ] && [ "$RUNTIME_BASE_REF" != "" ]; then
SELECTED_IMAGE="$RUNTIME_BASE_REF"
else
if ! docker pull "$DEFAULT_IMAGE" >/dev/null 2>&1; then
ALT_REGISTRY="${{ env.REGISTRY_URL }}"
@@ -929,8 +931,8 @@ jobs:
# Job 4: Auto-deploy to Production (only for main branch)
deploy-production:
name: Auto-deploy to Production
needs: [changes, build, runtime-base]
if: (github.ref_name == 'main' || github.head_ref == 'main' || (github.ref_name == '' && contains(github.ref, 'main'))) && needs.changes.outputs.needs_build == 'true'
needs: [changes, build]
if: always() && (github.ref_name == 'main' || github.head_ref == 'main' || (github.ref_name == '' && contains(github.ref, 'main'))) && needs.changes.outputs.needs_build == 'true'
runs-on: ubuntu-latest
environment:
name: production