This is an automated email from the ASF dual-hosted git repository.

potiuk pushed a commit to branch fork-ci-test-merge-commit
in repository https://gitbox.apache.org/repos/asf/airflow.git

commit 8cea4d0ce7cc901cd97c92dd5f621ad0e735dc56
Author: Jarek Potiuk <[email protected]>
AuthorDate: Mon Nov 16 02:04:38 2026 +0900

    Run the merge step only when there is a merge
    
    GitHub reads a local action from the checkout before the step's inputs
    count, so a matrix entry that skips its checkout, or a constraints run
    that builds an older release, failed on the missing action even with
    nothing to merge.
    
    Generated-by: Claude Opus 5
    Claude-Session: https://claude.ai/code/session_01NyQq9U7i5HhjDgrQ9qd3gq
---
 .github/actions/merge-with-base/action.yml                |  3 ++-
 .github/workflows/additional-ci-image-checks.yml          |  1 +
 .github/workflows/additional-prod-image-tests.yml         |  4 ++++
 .github/workflows/agent-framework-tests.yml               |  1 +
 .github/workflows/airflow-distributions-tests.yml         |  1 +
 .github/workflows/airflow-e2e-tests.yml                   |  1 +
 .github/workflows/basic-tests.yml                         | 10 ++++++++++
 .github/workflows/ci-amd.yml                              |  8 ++++++++
 .github/workflows/ci-arm.yml                              |  8 ++++++++
 .github/workflows/ci-image-build.yml                      |  3 ++-
 .github/workflows/ci-image-checks.yml                     |  4 ++++
 .github/workflows/dependency-upgrade-summary.yml          |  1 +
 .github/workflows/finalize-tests.yml                      |  1 +
 .github/workflows/generate-constraints.yml                |  3 ++-
 .github/workflows/helm-tests.yml                          |  2 ++
 .github/workflows/integration-system-tests.yml            |  3 +++
 .github/workflows/k8s-tests.yml                           |  2 ++
 .github/workflows/kustomize-overlays-tests.yml            |  1 +
 .github/workflows/openlineage-e2e-compat-tests.yml        |  1 +
 .github/workflows/prod-image-build.yml                    |  1 +
 .github/workflows/prod-packages-build.yml                 |  1 +
 .github/workflows/push-image-cache.yml                    |  2 ++
 .github/workflows/run-unit-tests.yml                      |  1 +
 .github/workflows/test-providers.yml                      |  2 ++
 .github/workflows/ui-e2e-tests.yml                        |  1 +
 dev/breeze/doc/ci/08_fork_ci_for_external_contributors.md |  7 +++++--
 scripts/ci/prek/check_fork_ci_tests_merge.py              | 10 ++++++++--
 scripts/tests/ci/prek/test_check_fork_ci_tests_merge.py   | 11 ++++++++++-
 28 files changed, 86 insertions(+), 8 deletions(-)

diff --git a/.github/actions/merge-with-base/action.yml 
b/.github/actions/merge-with-base/action.yml
index 4d51f6fde9a..2451ba616ec 100644
--- a/.github/actions/merge-with-base/action.yml
+++ b/.github/actions/merge-with-base/action.yml
@@ -19,7 +19,8 @@
 name: 'Merge with the base branch'
 description: >-
   Replace the checked-out pushed commit of a fork CI run with its merge into 
the base branch, the
-  commit a pull_request run of project CI tests (AIP-120). Does nothing when 
merge-with is empty.
+  commit a pull_request run of project CI tests (AIP-120). Callers run it only 
when merge-with is
+  set: the action is read from the checkout, which an older ref or a skipped 
checkout lacks.
 inputs:
   merge-with:
     description: >-
diff --git a/.github/workflows/additional-ci-image-checks.yml 
b/.github/workflows/additional-ci-image-checks.yml
index 30778463455..aff261cb0f0 100644
--- a/.github/workflows/additional-ci-image-checks.yml
+++ b/.github/workflows/additional-ci-image-checks.yml
@@ -89,6 +89,7 @@ jobs:
         with:
           persist-credentials: false
       - name: "Merge with the base branch"
+        if: inputs.merge-with != ''
         uses: ./.github/actions/merge-with-base
         with:
           merge-with: ${{ inputs.merge-with }}
diff --git a/.github/workflows/additional-prod-image-tests.yml 
b/.github/workflows/additional-prod-image-tests.yml
index b0bd58a959d..505d56d2649 100644
--- a/.github/workflows/additional-prod-image-tests.yml
+++ b/.github/workflows/additional-prod-image-tests.yml
@@ -196,6 +196,7 @@ jobs:
           fetch-depth: 2
           persist-credentials: false
       - name: "Merge with the base branch"
+        if: inputs.merge-with != ''
         uses: ./.github/actions/merge-with-base
         with:
           merge-with: ${{ inputs.merge-with }}
@@ -239,6 +240,7 @@ jobs:
           fetch-depth: 2
           persist-credentials: false
       - name: "Merge with the base branch"
+        if: inputs.merge-with != ''
         uses: ./.github/actions/merge-with-base
         with:
           merge-with: ${{ inputs.merge-with }}
@@ -274,6 +276,7 @@ jobs:
           fetch-depth: 2
           persist-credentials: false
       - name: "Merge with the base branch"
+        if: inputs.merge-with != ''
         uses: ./.github/actions/merge-with-base
         with:
           merge-with: ${{ inputs.merge-with }}
@@ -544,6 +547,7 @@ jobs:
           fetch-depth: 2
           persist-credentials: false
       - name: "Merge with the base branch"
+        if: inputs.merge-with != ''
         uses: ./.github/actions/merge-with-base
         with:
           merge-with: ${{ inputs.merge-with }}
diff --git a/.github/workflows/agent-framework-tests.yml 
b/.github/workflows/agent-framework-tests.yml
index a9d065d7d0e..51098b48e0a 100644
--- a/.github/workflows/agent-framework-tests.yml
+++ b/.github/workflows/agent-framework-tests.yml
@@ -83,6 +83,7 @@ jobs:
         with:
           persist-credentials: false
       - name: "Merge with the base branch"
+        if: inputs.merge-with != ''
         uses: ./.github/actions/merge-with-base
         with:
           merge-with: ${{ inputs.merge-with }}
diff --git a/.github/workflows/airflow-distributions-tests.yml 
b/.github/workflows/airflow-distributions-tests.yml
index 2ed3ec4eaf8..99a6374d03a 100644
--- a/.github/workflows/airflow-distributions-tests.yml
+++ b/.github/workflows/airflow-distributions-tests.yml
@@ -103,6 +103,7 @@ jobs:
         with:
           persist-credentials: false
       - name: "Merge with the base branch"
+        if: inputs.merge-with != ''
         uses: ./.github/actions/merge-with-base
         with:
           merge-with: ${{ inputs.merge-with }}
diff --git a/.github/workflows/airflow-e2e-tests.yml 
b/.github/workflows/airflow-e2e-tests.yml
index 3d513eb3c85..6299cca56a1 100644
--- a/.github/workflows/airflow-e2e-tests.yml
+++ b/.github/workflows/airflow-e2e-tests.yml
@@ -120,6 +120,7 @@ jobs:
           fetch-depth: 2
           persist-credentials: false
       - name: "Merge with the base branch"
+        if: inputs.merge-with != ''
         uses: ./.github/actions/merge-with-base
         with:
           merge-with: ${{ inputs.merge-with }}
diff --git a/.github/workflows/basic-tests.yml 
b/.github/workflows/basic-tests.yml
index e23c8582a9f..14e68490b11 100644
--- a/.github/workflows/basic-tests.yml
+++ b/.github/workflows/basic-tests.yml
@@ -124,6 +124,7 @@ jobs:
           fetch-depth: 0
           persist-credentials: false
       - name: "Merge with the base branch"
+        if: inputs.merge-with != ''
         uses: ./.github/actions/merge-with-base
         with:
           merge-with: ${{ inputs.merge-with }}
@@ -146,6 +147,7 @@ jobs:
           fetch-depth: 0
           persist-credentials: false
       - name: "Merge with the base branch"
+        if: inputs.merge-with != ''
         uses: ./.github/actions/merge-with-base
         with:
           merge-with: ${{ inputs.merge-with }}
@@ -179,6 +181,7 @@ jobs:
           fetch-depth: 1
           persist-credentials: false
       - name: "Merge with the base branch"
+        if: inputs.merge-with != ''
         uses: ./.github/actions/merge-with-base
         with:
           merge-with: ${{ inputs.merge-with }}
@@ -224,6 +227,7 @@ jobs:
           fetch-depth: 1
           persist-credentials: false
       - name: "Merge with the base branch"
+        if: inputs.merge-with != ''
         uses: ./.github/actions/merge-with-base
         with:
           merge-with: ${{ inputs.merge-with }}
@@ -258,6 +262,7 @@ jobs:
         with:
           persist-credentials: false
       - name: "Merge with the base branch"
+        if: inputs.merge-with != ''
         uses: ./.github/actions/merge-with-base
         with:
           merge-with: ${{ inputs.merge-with }}
@@ -298,6 +303,7 @@ jobs:
         with:
           persist-credentials: false
       - name: "Merge with the base branch"
+        if: inputs.merge-with != ''
         uses: ./.github/actions/merge-with-base
         with:
           merge-with: ${{ inputs.merge-with }}
@@ -338,6 +344,7 @@ jobs:
           fetch-depth: 2
           persist-credentials: false
       - name: "Merge with the base branch"
+        if: inputs.merge-with != ''
         uses: ./.github/actions/merge-with-base
         with:
           merge-with: ${{ inputs.merge-with }}
@@ -402,6 +409,7 @@ jobs:
           fetch-depth: 2
           persist-credentials: false
       - name: "Merge with the base branch"
+        if: inputs.merge-with != ''
         uses: ./.github/actions/merge-with-base
         with:
           merge-with: ${{ inputs.merge-with }}
@@ -426,6 +434,7 @@ jobs:
         with:
           persist-credentials: false
       - name: "Merge with the base branch"
+        if: inputs.merge-with != ''
         uses: ./.github/actions/merge-with-base
         with:
           merge-with: ${{ inputs.merge-with }}
@@ -478,6 +487,7 @@ jobs:
         with:
           persist-credentials: false
       - name: "Merge with the base branch"
+        if: inputs.merge-with != ''
         uses: ./.github/actions/merge-with-base
         with:
           merge-with: ${{ inputs.merge-with }}
diff --git a/.github/workflows/ci-amd.yml b/.github/workflows/ci-amd.yml
index e4c12affa35..76a57dc477b 100644
--- a/.github/workflows/ci-amd.yml
+++ b/.github/workflows/ci-amd.yml
@@ -735,6 +735,7 @@ jobs:
         with:
           persist-credentials: false
       - name: "Merge with the base branch"
+        if: needs.build-info.outputs.merge-with != ''
         uses: ./.github/actions/merge-with-base
         with:
           merge-with: ${{ needs.build-info.outputs.merge-with }}
@@ -781,6 +782,7 @@ jobs:
         with:
           persist-credentials: false
       - name: "Merge with the base branch"
+        if: needs.build-info.outputs.merge-with != ''
         uses: ./.github/actions/merge-with-base
         with:
           merge-with: ${{ needs.build-info.outputs.merge-with }}
@@ -1407,6 +1409,7 @@ jobs:
         with:
           persist-credentials: false
       - name: "Merge with the base branch"
+        if: needs.build-info.outputs.merge-with != ''
         uses: ./.github/actions/merge-with-base
         with:
           merge-with: ${{ needs.build-info.outputs.merge-with }}
@@ -1474,6 +1477,7 @@ jobs:
         with:
           persist-credentials: false
       - name: "Merge with the base branch"
+        if: needs.build-info.outputs.merge-with != ''
         uses: ./.github/actions/merge-with-base
         with:
           merge-with: ${{ needs.build-info.outputs.merge-with }}
@@ -1520,6 +1524,7 @@ jobs:
         with:
           persist-credentials: false
       - name: "Merge with the base branch"
+        if: needs.build-info.outputs.merge-with != ''
         uses: ./.github/actions/merge-with-base
         with:
           merge-with: ${{ needs.build-info.outputs.merge-with }}
@@ -1554,6 +1559,7 @@ jobs:
         with:
           persist-credentials: false
       - name: "Merge with the base branch"
+        if: needs.build-info.outputs.merge-with != ''
         uses: ./.github/actions/merge-with-base
         with:
           merge-with: ${{ needs.build-info.outputs.merge-with }}
@@ -1614,6 +1620,7 @@ jobs:
         with:
           persist-credentials: false
       - name: "Merge with the base branch"
+        if: needs.build-info.outputs.merge-with != ''
         uses: ./.github/actions/merge-with-base
         with:
           merge-with: ${{ needs.build-info.outputs.merge-with }}
@@ -1650,6 +1657,7 @@ jobs:
         with:
           persist-credentials: false
       - name: "Merge with the base branch"
+        if: needs.build-info.outputs.merge-with != ''
         uses: ./.github/actions/merge-with-base
         with:
           merge-with: ${{ needs.build-info.outputs.merge-with }}
diff --git a/.github/workflows/ci-arm.yml b/.github/workflows/ci-arm.yml
index bf2423afb41..98d8f07c50a 100644
--- a/.github/workflows/ci-arm.yml
+++ b/.github/workflows/ci-arm.yml
@@ -611,6 +611,7 @@ jobs:
         with:
           persist-credentials: false
       - name: "Merge with the base branch"
+        if: needs.build-info.outputs.merge-with != ''
         uses: ./.github/actions/merge-with-base
         with:
           merge-with: ${{ needs.build-info.outputs.merge-with }}
@@ -657,6 +658,7 @@ jobs:
         with:
           persist-credentials: false
       - name: "Merge with the base branch"
+        if: needs.build-info.outputs.merge-with != ''
         uses: ./.github/actions/merge-with-base
         with:
           merge-with: ${{ needs.build-info.outputs.merge-with }}
@@ -1283,6 +1285,7 @@ jobs:
         with:
           persist-credentials: false
       - name: "Merge with the base branch"
+        if: needs.build-info.outputs.merge-with != ''
         uses: ./.github/actions/merge-with-base
         with:
           merge-with: ${{ needs.build-info.outputs.merge-with }}
@@ -1350,6 +1353,7 @@ jobs:
         with:
           persist-credentials: false
       - name: "Merge with the base branch"
+        if: needs.build-info.outputs.merge-with != ''
         uses: ./.github/actions/merge-with-base
         with:
           merge-with: ${{ needs.build-info.outputs.merge-with }}
@@ -1396,6 +1400,7 @@ jobs:
         with:
           persist-credentials: false
       - name: "Merge with the base branch"
+        if: needs.build-info.outputs.merge-with != ''
         uses: ./.github/actions/merge-with-base
         with:
           merge-with: ${{ needs.build-info.outputs.merge-with }}
@@ -1430,6 +1435,7 @@ jobs:
         with:
           persist-credentials: false
       - name: "Merge with the base branch"
+        if: needs.build-info.outputs.merge-with != ''
         uses: ./.github/actions/merge-with-base
         with:
           merge-with: ${{ needs.build-info.outputs.merge-with }}
@@ -1490,6 +1496,7 @@ jobs:
         with:
           persist-credentials: false
       - name: "Merge with the base branch"
+        if: needs.build-info.outputs.merge-with != ''
         uses: ./.github/actions/merge-with-base
         with:
           merge-with: ${{ needs.build-info.outputs.merge-with }}
@@ -1526,6 +1533,7 @@ jobs:
         with:
           persist-credentials: false
       - name: "Merge with the base branch"
+        if: needs.build-info.outputs.merge-with != ''
         uses: ./.github/actions/merge-with-base
         with:
           merge-with: ${{ needs.build-info.outputs.merge-with }}
diff --git a/.github/workflows/ci-image-build.yml 
b/.github/workflows/ci-image-build.yml
index e4d70b16aa1..5c17b078649 100644
--- a/.github/workflows/ci-image-build.yml
+++ b/.github/workflows/ci-image-build.yml
@@ -162,9 +162,10 @@ jobs:
           ref: ${{ inputs.checkout-ref }}
           persist-credentials: false
       - name: "Merge with the base branch"
+        if: inputs.checkout-ref == '' && inputs.merge-with != ''
         uses: ./.github/actions/merge-with-base
         with:
-          merge-with: ${{ inputs.checkout-ref == '' && inputs.merge-with || '' 
}}
+          merge-with: ${{ inputs.merge-with }}
       # A local action is read from the workspace, and `checkout-ref` may be a 
release ref cut
       # before the stash actions existed, so they are loaded from the 
workflow's own version. The
       # runner-preparing scripts too: an older `make_mnt_writeable.sh` empties 
/mnt, which on
diff --git a/.github/workflows/ci-image-checks.yml 
b/.github/workflows/ci-image-checks.yml
index dc5c658629e..ef6adf242e3 100644
--- a/.github/workflows/ci-image-checks.yml
+++ b/.github/workflows/ci-image-checks.yml
@@ -150,6 +150,7 @@ jobs:
         with:
           persist-credentials: false
       - name: "Merge with the base branch"
+        if: inputs.merge-with != ''
         uses: ./.github/actions/merge-with-base
         with:
           merge-with: ${{ inputs.merge-with }}
@@ -226,6 +227,7 @@ jobs:
         with:
           persist-credentials: false
       - name: "Merge with the base branch"
+        if: inputs.merge-with != ''
         uses: ./.github/actions/merge-with-base
         with:
           merge-with: ${{ inputs.merge-with }}
@@ -391,6 +393,7 @@ jobs:
         with:
           persist-credentials: false
       - name: "Merge with the base branch"
+        if: inputs.merge-with != ''
         uses: ./.github/actions/merge-with-base
         with:
           merge-with: ${{ inputs.merge-with }}
@@ -530,6 +533,7 @@ jobs:
           fetch-depth: 2
           persist-credentials: false
       - name: "Merge with the base branch"
+        if: inputs.merge-with != ''
         uses: ./.github/actions/merge-with-base
         with:
           merge-with: ${{ inputs.merge-with }}
diff --git a/.github/workflows/dependency-upgrade-summary.yml 
b/.github/workflows/dependency-upgrade-summary.yml
index ae827b1f32f..497fe0ef26c 100644
--- a/.github/workflows/dependency-upgrade-summary.yml
+++ b/.github/workflows/dependency-upgrade-summary.yml
@@ -72,6 +72,7 @@ jobs:
         with:
           persist-credentials: false
       - name: "Merge with the base branch"
+        if: inputs.merge-with != ''
         uses: ./.github/actions/merge-with-base
         with:
           merge-with: ${{ inputs.merge-with }}
diff --git a/.github/workflows/finalize-tests.yml 
b/.github/workflows/finalize-tests.yml
index d7571f3d152..6ace614f400 100644
--- a/.github/workflows/finalize-tests.yml
+++ b/.github/workflows/finalize-tests.yml
@@ -111,6 +111,7 @@ jobs:
           # Needed to perform push action
           persist-credentials: false
       - name: "Merge with the base branch"
+        if: inputs.merge-with != ''
         uses: ./.github/actions/merge-with-base
         with:
           merge-with: ${{ inputs.merge-with }}
diff --git a/.github/workflows/generate-constraints.yml 
b/.github/workflows/generate-constraints.yml
index c7d5f5f9132..a15d2930ea7 100644
--- a/.github/workflows/generate-constraints.yml
+++ b/.github/workflows/generate-constraints.yml
@@ -124,9 +124,10 @@ jobs:
           ref: ${{ inputs.checkout-ref }}
           persist-credentials: false
       - name: "Merge with the base branch"
+        if: inputs.checkout-ref == '' && inputs.merge-with != ''
         uses: ./.github/actions/merge-with-base
         with:
-          merge-with: ${{ inputs.checkout-ref == '' && inputs.merge-with || '' 
}}
+          merge-with: ${{ inputs.merge-with }}
       - name: "Prepare breeze & CI image: ${{ matrix.python-version }}"
         uses: ./.github/actions/prepare_breeze_and_image
         with:
diff --git a/.github/workflows/helm-tests.yml b/.github/workflows/helm-tests.yml
index 4c7a3c3be7a..5c5c1dbd1df 100644
--- a/.github/workflows/helm-tests.yml
+++ b/.github/workflows/helm-tests.yml
@@ -89,6 +89,7 @@ jobs:
         with:
           persist-credentials: false
       - name: "Merge with the base branch"
+        if: inputs.merge-with != ''
         uses: ./.github/actions/merge-with-base
         with:
           merge-with: ${{ inputs.merge-with }}
@@ -124,6 +125,7 @@ jobs:
         with:
           persist-credentials: false
       - name: "Merge with the base branch"
+        if: inputs.merge-with != ''
         uses: ./.github/actions/merge-with-base
         with:
           merge-with: ${{ inputs.merge-with }}
diff --git a/.github/workflows/integration-system-tests.yml 
b/.github/workflows/integration-system-tests.yml
index eb715b94dab..0e250cbafeb 100644
--- a/.github/workflows/integration-system-tests.yml
+++ b/.github/workflows/integration-system-tests.yml
@@ -111,6 +111,7 @@ jobs:
         with:
           persist-credentials: false
       - name: "Merge with the base branch"
+        if: inputs.merge-with != ''
         uses: ./.github/actions/merge-with-base
         with:
           merge-with: ${{ inputs.merge-with }}
@@ -168,6 +169,7 @@ jobs:
         with:
           persist-credentials: false
       - name: "Merge with the base branch"
+        if: inputs.merge-with != ''
         uses: ./.github/actions/merge-with-base
         with:
           merge-with: ${{ inputs.merge-with }}
@@ -217,6 +219,7 @@ jobs:
         with:
           persist-credentials: false
       - name: "Merge with the base branch"
+        if: inputs.merge-with != ''
         uses: ./.github/actions/merge-with-base
         with:
           merge-with: ${{ inputs.merge-with }}
diff --git a/.github/workflows/k8s-tests.yml b/.github/workflows/k8s-tests.yml
index 2c24af024a0..0ae63d23613 100644
--- a/.github/workflows/k8s-tests.yml
+++ b/.github/workflows/k8s-tests.yml
@@ -102,6 +102,7 @@ jobs:
         with:
           persist-credentials: false
       - name: "Merge with the base branch"
+        if: inputs.merge-with != ''
         uses: ./.github/actions/merge-with-base
         with:
           merge-with: ${{ inputs.merge-with }}
@@ -186,6 +187,7 @@ jobs:
         with:
           persist-credentials: false
       - name: "Merge with the base branch"
+        if: inputs.merge-with != ''
         uses: ./.github/actions/merge-with-base
         with:
           merge-with: ${{ inputs.merge-with }}
diff --git a/.github/workflows/kustomize-overlays-tests.yml 
b/.github/workflows/kustomize-overlays-tests.yml
index 245cc12015b..6814b44f9ce 100644
--- a/.github/workflows/kustomize-overlays-tests.yml
+++ b/.github/workflows/kustomize-overlays-tests.yml
@@ -81,6 +81,7 @@ jobs:
         with:
           persist-credentials: false
       - name: "Merge with the base branch"
+        if: inputs.merge-with != ''
         uses: ./.github/actions/merge-with-base
         with:
           merge-with: ${{ inputs.merge-with }}
diff --git a/.github/workflows/openlineage-e2e-compat-tests.yml 
b/.github/workflows/openlineage-e2e-compat-tests.yml
index 10906b68134..f2a6f7ecd5b 100644
--- a/.github/workflows/openlineage-e2e-compat-tests.yml
+++ b/.github/workflows/openlineage-e2e-compat-tests.yml
@@ -81,6 +81,7 @@ jobs:
           fetch-depth: 2
           persist-credentials: false
       - name: "Merge with the base branch"
+        if: ${{ !startsWith(inputs.airflow-version, '2.') && inputs.merge-with 
!= '' }}
         uses: ./.github/actions/merge-with-base
         with:
           merge-with: ${{ inputs.merge-with }}
diff --git a/.github/workflows/prod-image-build.yml 
b/.github/workflows/prod-image-build.yml
index c2f08049e56..d88e15b8fc5 100644
--- a/.github/workflows/prod-image-build.yml
+++ b/.github/workflows/prod-image-build.yml
@@ -191,6 +191,7 @@ jobs:
         with:
           persist-credentials: false
       - name: "Merge with the base branch"
+        if: inputs.merge-with != ''
         uses: ./.github/actions/merge-with-base
         with:
           merge-with: ${{ inputs.merge-with }}
diff --git a/.github/workflows/prod-packages-build.yml 
b/.github/workflows/prod-packages-build.yml
index 2b57e1d75a3..e8a13968fec 100644
--- a/.github/workflows/prod-packages-build.yml
+++ b/.github/workflows/prod-packages-build.yml
@@ -74,6 +74,7 @@ jobs:
         with:
           persist-credentials: false
       - name: "Merge with the base branch"
+        if: inputs.merge-with != ''
         uses: ./.github/actions/merge-with-base
         with:
           merge-with: ${{ inputs.merge-with }}
diff --git a/.github/workflows/push-image-cache.yml 
b/.github/workflows/push-image-cache.yml
index 666ff3c8081..63d14e5ee7d 100644
--- a/.github/workflows/push-image-cache.yml
+++ b/.github/workflows/push-image-cache.yml
@@ -125,6 +125,7 @@ jobs:
         with:
           persist-credentials: false
       - name: "Merge with the base branch"
+        if: inputs.merge-with != ''
         uses: ./.github/actions/merge-with-base
         with:
           merge-with: ${{ inputs.merge-with }}
@@ -199,6 +200,7 @@ jobs:
         with:
           persist-credentials: false
       - name: "Merge with the base branch"
+        if: inputs.merge-with != ''
         uses: ./.github/actions/merge-with-base
         with:
           merge-with: ${{ inputs.merge-with }}
diff --git a/.github/workflows/run-unit-tests.yml 
b/.github/workflows/run-unit-tests.yml
index 53fbcc5f62f..80d700933b1 100644
--- a/.github/workflows/run-unit-tests.yml
+++ b/.github/workflows/run-unit-tests.yml
@@ -207,6 +207,7 @@ jobs:
         with:
           persist-credentials: false
       - name: "Merge with the base branch"
+        if: inputs.merge-with != ''
         uses: ./.github/actions/merge-with-base
         with:
           merge-with: ${{ inputs.merge-with }}
diff --git a/.github/workflows/test-providers.yml 
b/.github/workflows/test-providers.yml
index b0171693834..3d3b907b852 100644
--- a/.github/workflows/test-providers.yml
+++ b/.github/workflows/test-providers.yml
@@ -104,6 +104,7 @@ jobs:
         with:
           persist-credentials: false
       - name: "Merge with the base branch"
+        if: inputs.merge-with != ''
         uses: ./.github/actions/merge-with-base
         with:
           merge-with: ${{ inputs.merge-with }}
@@ -219,6 +220,7 @@ jobs:
         with:
           persist-credentials: false
       - name: "Merge with the base branch"
+        if: inputs.merge-with != ''
         uses: ./.github/actions/merge-with-base
         with:
           merge-with: ${{ inputs.merge-with }}
diff --git a/.github/workflows/ui-e2e-tests.yml 
b/.github/workflows/ui-e2e-tests.yml
index 4b1417b0b1e..a295ca1857c 100644
--- a/.github/workflows/ui-e2e-tests.yml
+++ b/.github/workflows/ui-e2e-tests.yml
@@ -115,6 +115,7 @@ jobs:
           fetch-depth: 2
           persist-credentials: false
       - name: "Merge with the base branch"
+        if: inputs.merge-with != ''
         uses: ./.github/actions/merge-with-base
         with:
           merge-with: ${{ inputs.merge-with }}
diff --git a/dev/breeze/doc/ci/08_fork_ci_for_external_contributors.md 
b/dev/breeze/doc/ci/08_fork_ci_for_external_contributors.md
index b9faf3646c8..a20b8ea264e 100644
--- a/dev/breeze/doc/ci/08_fork_ci_for_external_contributors.md
+++ b/dev/breeze/doc/ci/08_fork_ci_for_external_contributors.md
@@ -501,12 +501,15 @@ anything, with the `merge-with-base` action 
(`.github/actions/merge-with-base`):
   so every job makes the same merge commit, which is then checked out in place 
of the pushed commit.
 - The merge needs no write access: nothing is pushed, and fork runs keep a 
read-only token.
 - `merge-with` is passed to every reusable workflow a fork run calls, and is 
empty in every run in
-  `apache/airflow`, where the action does nothing. A workflow whose checkout 
takes another ref
+  `apache/airflow`. Each merge step runs only when it is set: the action is 
read from the checkout,
+  and a checkout of an older ref, such as a release a constraints run builds 
from, or a checkout a
+  matrix entry skips, has no such action. A workflow whose checkout takes 
another ref
   (`checkout-ref`, such as a target branch to build an image from) merges only 
when it checks out
   the pushed commit.
 - The `check-fork-ci-tests-merge` prek hook keeps it that way: in 
`ci-amd.yml`, `ci-arm.yml` and every
   workflow they call, each call passes `merge-with`, and each job that checks 
out the pushed commit
-  into the workspace merges after its last such checkout. `gate`, 
`build-info`, `notify-slack` and
+  into the workspace merges after its last such checkout, in a step whose 
`if:` checks `merge-with`.
+  `gate`, `build-info`, `notify-slack` and
   `summarize-warnings` are exempt: they read the pushed commit or only report 
on the run.
 - `build-info` names the merge in a step, "Test merged with apache/airflow
   `<branch>`@`<commit>`, merge base `<commit>`", from which the reconciler 
learns what the run
diff --git a/scripts/ci/prek/check_fork_ci_tests_merge.py 
b/scripts/ci/prek/check_fork_ci_tests_merge.py
index 41c999ff4cb..53a685669e2 100755
--- a/scripts/ci/prek/check_fork_ci_tests_merge.py
+++ b/scripts/ci/prek/check_fork_ci_tests_merge.py
@@ -31,7 +31,7 @@ check covers ``ci-amd.yml``, ``ci-arm.yml`` and every 
workflow they call, direct
 
 - every call of a reusable workflow passes ``merge-with``, and every reusable 
workflow takes it;
 - in every job that checks out the pushed commit into the workspace root, the 
merge step follows
-  the last such checkout.
+  the last such checkout, with an ``if:`` that runs it only when 
``merge-with`` is set.
 
 A checkout of another ref (a constraints branch, the gate configuration) or 
into a sub-directory is
 not the pull request's sources and is not counted.
@@ -117,7 +117,13 @@ def check_job(workflow_name: str, job_id: str, job: 
dict[str, Any]) -> list[str]
             f"job [yellow]{job_id}[/] checks out the pushed commit without a 
`{MERGE_ACTION}` step "
             "after its last such checkout"
         ]
-    return []
+    # The action is read from the checkout, which an older ref or a skipped 
checkout lacks, so it may
+    # only be loaded when there is something to merge.
+    return [
+        f"job [yellow]{job_id}[/] runs `{MERGE_ACTION}` without an `if:` that 
checks `merge-with`"
+        for index in merges
+        if "merge-with" not in str(steps[index].get("if", ""))
+    ]
 
 
 def check_workflow(name: str, workflow: dict[Any, Any]) -> list[str]:
diff --git a/scripts/tests/ci/prek/test_check_fork_ci_tests_merge.py 
b/scripts/tests/ci/prek/test_check_fork_ci_tests_merge.py
index f2f90421fc4..ae7f6e9b6a4 100644
--- a/scripts/tests/ci/prek/test_check_fork_ci_tests_merge.py
+++ b/scripts/tests/ci/prek/test_check_fork_ci_tests_merge.py
@@ -21,7 +21,11 @@ import yaml
 from check_fork_ci_tests_merge import MERGE_ACTION, check_job, check_workflow, 
main
 
 CHECKOUT = {"uses": "actions/checkout@v7"}
-MERGE = {"uses": MERGE_ACTION, "with": {"merge-with": "${{ inputs.merge-with 
}}"}}
+MERGE = {
+    "if": "inputs.merge-with != ''",
+    "uses": MERGE_ACTION,
+    "with": {"merge-with": "${{ inputs.merge-with }}"},
+}
 
 
 @pytest.mark.parametrize(
@@ -29,6 +33,11 @@ MERGE = {"uses": MERGE_ACTION, "with": {"merge-with": "${{ 
inputs.merge-with }}"
     [
         pytest.param([CHECKOUT, MERGE], True, id="merge-after-checkout"),
         pytest.param([CHECKOUT], False, id="no-merge"),
+        pytest.param(
+            [CHECKOUT, {key: value for key, value in MERGE.items() if key != 
"if"}],
+            False,
+            id="merge-unguarded",
+        ),
         pytest.param([MERGE, CHECKOUT], False, id="merge-before-checkout"),
         pytest.param(
             [CHECKOUT, MERGE, {"uses": "actions/checkout@v7", "with": {"ref": 
"${{ github.sha }}"}}],

Reply via email to