From 28d498012ae123088004c14bf896c0bce783c584 Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Sun, 2 Aug 2026 22:04:48 +0530 Subject: [PATCH] ci(patch): resolve the frappe ref by type and only fall back for branches The probe used --heads with a bare name, so it could not describe a tag push and would have fallen back to develop for one. Resolve a fully qualified ref from the event instead: the PR base or pushed branch under refs/heads, a tag under refs/tags, and fail loudly on an unrecognised ref type. Only branch refs are eligible for the develop fallback. A tag that is absent from frappe is a real error, not a stacked-PR base, so it still fails. --- .github/workflows/patch.yml | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/.github/workflows/patch.yml b/.github/workflows/patch.yml index 343e9767067..f6c74bb5cc9 100644 --- a/.github/workflows/patch.yml +++ b/.github/workflows/patch.yml @@ -171,17 +171,30 @@ jobs: update_to_version 16 3.14 echo "Updating to latest version" - base_ref="${GITHUB_BASE_REF:-${GITHUB_REF##*/}}" + fallback_to_develop=0 + if [ -n "${GITHUB_BASE_REF:-}" ]; then + frappe_ref="refs/heads/$GITHUB_BASE_REF" + fallback_to_develop=1 + elif [ "${GITHUB_REF_TYPE:-}" = "branch" ]; then + frappe_ref="refs/heads/$GITHUB_REF_NAME" + fallback_to_develop=1 + elif [ "${GITHUB_REF_TYPE:-}" = "tag" ]; then + frappe_ref="refs/tags/$GITHUB_REF_NAME" + else + echo "Unsupported GitHub ref type: '${GITHUB_REF_TYPE:-unset}'" + exit 1 + fi + ls_remote_status=0 - git -C "apps/frappe" ls-remote --exit-code --heads upstream "$base_ref" >/dev/null \ + git -C "apps/frappe" ls-remote --exit-code upstream "$frappe_ref" >/dev/null \ || ls_remote_status=$? - if [ "$ls_remote_status" -eq 2 ]; then - echo "frappe has no '$base_ref' branch; falling back to develop" - base_ref=develop + if [ "$ls_remote_status" -eq 2 ] && [ "$fallback_to_develop" -eq 1 ]; then + echo "frappe has no '$frappe_ref'; falling back to develop" + frappe_ref=refs/heads/develop elif [ "$ls_remote_status" -ne 0 ]; then exit "$ls_remote_status" fi - git -C "apps/frappe" fetch --depth 1 upstream "$base_ref" + git -C "apps/frappe" fetch --depth 1 upstream "$frappe_ref" git -C "apps/frappe" checkout -q -f FETCH_HEAD git -C "apps/erpnext" checkout -q -f "$GITHUB_SHA"