Skip to content

Commit 633c0ed

Browse files
committed
Fix CI build scripts to dynamically detect fork repository names
1 parent f77c6f2 commit 633c0ed

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

hack/jenkins/build_iso.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,12 @@ git config user.email "minikube-bot@google.com"
8888
if [ "$release" = false ]; then
8989
# Update the user's PR with newly build ISO
9090

91-
git remote add ${ghprbPullAuthorLogin} git@github.com:${ghprbPullAuthorLogin}/minikube.git
91+
# Dynamically determine the fork repository name from the PR URL or git remote
92+
FORK_REPO_NAME=$(gh pr view ${ghprbPullId} --json headRepository --jq '.headRepository.name' 2>/dev/null || echo "minikube")
93+
94+
# Try SSH first, fallback to HTTPS if SSH fails
95+
git remote add ${ghprbPullAuthorLogin} git@github.com:${ghprbPullAuthorLogin}/${FORK_REPO_NAME}.git || \
96+
git remote add ${ghprbPullAuthorLogin} https://github.com/${ghprbPullAuthorLogin}/${FORK_REPO_NAME}.git
9297
git fetch ${ghprbPullAuthorLogin}
9398
git checkout -b ${ghprbPullAuthorLogin}-${ghprbSourceBranch} ${ghprbPullAuthorLogin}/${ghprbSourceBranch}
9499

hack/jenkins/kicbase_auto_build.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,12 @@ git config user.email "minikube-bot@google.com"
106106
if [ "$release" = false ]; then
107107
# Update the user's PR with the newly built kicbase image.
108108

109-
git remote add ${ghprbPullAuthorLogin} git@github.com:${ghprbPullAuthorLogin}/minikube.git
109+
# Dynamically determine the fork repository name from the PR URL or git remote
110+
FORK_REPO_NAME=$(gh pr view ${ghprbPullId} --json headRepository --jq '.headRepository.name' 2>/dev/null || echo "minikube")
111+
112+
# Try SSH first, fallback to HTTPS if SSH fails
113+
git remote add ${ghprbPullAuthorLogin} git@github.com:${ghprbPullAuthorLogin}/${FORK_REPO_NAME}.git || \
114+
git remote add ${ghprbPullAuthorLogin} https://github.com/${ghprbPullAuthorLogin}/${FORK_REPO_NAME}.git
110115
git fetch ${ghprbPullAuthorLogin}
111116
git checkout -b ${ghprbPullAuthorLogin}-${ghprbSourceBranch} ${ghprbPullAuthorLogin}/${ghprbSourceBranch}
112117

0 commit comments

Comments
 (0)