Skip to content

Commit 7cf0659

Browse files
committed
Fix CI logic for PRs run against external forks. [ci skip]
1 parent 4330138 commit 7cf0659

2 files changed

Lines changed: 15 additions & 5 deletions

File tree

.github/workflows/pr.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ jobs:
4545
SIRE_SILENT_PHONEHOME: 1
4646
SIRE_EMLE: 1
4747
REPO: "${{ github.event.pull_request.head.repo.full_name || github.repository }}"
48+
SIRE_REMOTE: "https://github.com/${{ github.event.pull_request.head.repo.full_name || github.repository }}.git"
4849
steps:
4950
#
5051
- uses: actions/checkout@v4

actions/generate_recipe.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,20 @@ def get_git_info(srcdir):
9191
"""Get the git remote URL and branch/tag."""
9292
gitdir = os.path.join(srcdir, ".git")
9393

94-
remote = run_cmd(
95-
f"git --git-dir={gitdir} --work-tree={srcdir} config --get remote.origin.url"
96-
)
97-
if not remote.endswith(".git"):
98-
remote += ".git"
94+
# For PR builds from external forks the checkout remote points to the base
95+
# repo, not the fork. The workflow sets SIRE_REMOTE to the fork's clone
96+
# URL so that rattler-build fetches from the right place.
97+
env_remote = os.environ.get("SIRE_REMOTE")
98+
if env_remote:
99+
remote = env_remote
100+
if not remote.endswith(".git"):
101+
remote += ".git"
102+
else:
103+
remote = run_cmd(
104+
f"git --git-dir={gitdir} --work-tree={srcdir} config --get remote.origin.url"
105+
)
106+
if not remote.endswith(".git"):
107+
remote += ".git"
99108

100109
branch = run_cmd(
101110
f"git --git-dir={gitdir} --work-tree={srcdir} rev-parse --abbrev-ref HEAD"

0 commit comments

Comments
 (0)