Skip to content

Commit e4a6563

Browse files
committed
fix: update gh commands to ensure correct repository context for PR
1 parent 5d9a8d4 commit e4a6563

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

.github/workflows/sync-upstream.yaml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,17 @@ jobs:
129129
TITLE="Merge upstream release ${UPSTREAM_TAG}"
130130
fi
131131
132-
OPEN=$(gh pr list --head "${SYNC_BRANCH}" --state open --json number --jq 'length')
132+
# --repo pins gh to this repo (detached mode) so --head is treated as a
133+
# branch in swisscom/sftpgo, not a cross-fork ref. Without it, gh infers
134+
# the head from the PAT user and the fork relationship, producing
135+
# "Head ref must be a branch / Head sha can't be blank".
136+
OPEN=$(gh pr list --repo "${GITHUB_REPOSITORY}" --head "${SYNC_BRANCH}" --state open --json number --jq 'length')
133137
if [ "${OPEN}" != "0" ]; then
134138
# PR already open — the force-push above updated it; just refresh title/body.
135-
gh pr edit "${SYNC_BRANCH}" --title "${TITLE}" --body-file pr-body.md
139+
gh pr edit "${SYNC_BRANCH}" --repo "${GITHUB_REPOSITORY}" --title "${TITLE}" --body-file pr-body.md
136140
else
137141
gh pr create \
142+
--repo "${GITHUB_REPOSITORY}" \
138143
--base "${TARGET_BRANCH}" \
139144
--head "${SYNC_BRANCH}" \
140145
--title "${TITLE}" \

0 commit comments

Comments
 (0)