Fix Android template E2E for PRs targeting stable branches (#57650)

On pull_request events github.ref_name is "<pr-number>/merge", which never
matches *-stable*, so the template E2E always cloned the template's main
branch. Template main now ships a Gradle 9.4.1 wrapper (bundling Kotlin
2.3.0), whose metadata the Kotlin 2.1.0 compiler used by
@react-native/gradle-plugin on 0.86 cannot read, breaking
:gradle-plugin:settings-plugin:compileKotlin on every PR to 0.86-stable.

Use github.base_ref (set on PR events) so PRs targeting stable branches
check out the matching template branch, falling back to ref_name for
branch pushes.
This commit is contained in:
Gabriel Donadel Dall'Agnol authored and GitHub committed 2026-07-23 20:18:19 +02:00
1 parent a8eb4f70c7
commit 27931ffc9c
1 file changed
+5 -3
@@ -56,9 +56,11 @@ jobs:
MAVEN_LOCAL=/tmp/react-native-tmp/maven-local
echo "Maven local path is $MAVEN_LOCAL"
# For stable branches, we want to use the stable branch of the template
# In all the other cases, we want to use "main"
BRANCH=${{ github.ref_name }}
# For stable branches, we want to use the stable branch of the template.
# In all the other cases, we want to use "main".
# On pull_request events, ref_name is "<pr-number>/merge", so use the
# PR base branch instead to keep targeting the matching template branch.
BRANCH=${{ github.base_ref || github.ref_name }}
if ! [[ $BRANCH == *-stable* ]]; then
BRANCH=main
fi