Skip to content

Commit 39b7fad

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

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

deploy/iso/minikube-iso/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
# test for 22020
16+
1517
FROM ubuntu:20.04
1618

1719
RUN apt-get update \

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)