Skip to content

ci: support cross-repo and private issue references in link-issue workflow - #36458

Merged
mbiuki merged 7 commits into
mainfrom
ci/link-issue-cross-repo-support
Jul 14, 2026
Merged

ci: support cross-repo and private issue references in link-issue workflow#36458
mbiuki merged 7 commits into
mainfrom
ci/link-issue-cross-repo-support

Conversation

@mbiuki

@mbiuki mbiuki commented Jul 7, 2026

Copy link
Copy Markdown
Member

Summary

  • Extends issue_comp_link-issue-to-pr.yml to accept owner/repo#NUMBER and full GitHub URL formats alongside the existing same-repo #NUMBER detection
  • Cross-repo references (e.g. Closes dotCMS/private-issues#642) now pass the check without requiring a public placeholder issue
  • Team-label validation passes gracefully when the linked issue is in a private/inaccessible repo
  • Same-repo-only side effects (PR-list comment on the issue, bare #N appended to PR body) are skipped for cross-repo references to avoid creating broken links
  • Failure comment updated to document all three supported reference formats

Test plan

  • PR with Fixes dotCMS/private-issues#N passes link-issue check
  • PR with Closes https://github.com/dotCMS/private-issues/issues/N passes link-issue check
  • PR with Fixes #N (same-repo) continues to pass and still gets the PR-list comment on the linked issue
  • PR with no issue reference still fails with the updated failure comment showing all three options

References

Closes #36457

🤖 Generated with Claude Code

The link-issue check previously only accepted same-repo `#NUMBER`
references, causing PRs that track work in private repos (e.g.
`dotCMS/private-issues#642`) to fail even with a valid issue link.

Changes:
- Detect `owner/repo#NUMBER` and full GitHub URL formats in PR body,
  in addition to same-repo `#NUMBER`, using closing keywords
  (closes/fixes/resolves and variants)
- Emit `is_cross_repo` and `cross_repo_owner_repo` outputs that flow
  through all downstream steps
- Team-label validation: for cross-repo issues, attempt to fetch
  labels and warn on access failure (private repos) rather than
  failing — same-repo validation is unchanged
- Skip same-repo-only side effects when `is_cross_repo=true`:
  posting a PR-list comment on the issue, and appending a bare `#N`
  to the PR body (which would create a broken same-repo link)
- Update failure comment to document cross-repo reference formats

Closes dotCMS/private-issues#642

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JHg1W7beD4Z1yLoTJpyXss
@mbiuki
mbiuki requested a review from a team as a code owner July 7, 2026 19:50
@github-actions github-actions Bot added the Area : CI/CD PR changes GitHub Actions/workflows label Jul 7, 2026
@mbiuki
mbiuki requested a review from nollymar July 7, 2026 19:51
@mbiuki mbiuki self-assigned this Jul 7, 2026
@claude

claude Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Claude finished @mbiuki's task in 4m 35s —— View job


Code Review: cross-repo issue reference support

  • Read PR diff
  • Analyze detection logic & downstream conditions
  • Post review

Reviewed .github/workflows/issue_comp_link-issue-to-pr.yml. The detection logic is well-structured and the two AI-review fixes landed correctly:

  • Priority ordering — same-repo #N (line 91-92) is extracted before any cross-repo pattern, so Fixes #123 can't be shadowed by a stray owner/repo#N. ✅
  • Self-reference routing — both the owner/repo#N branch (line 119) and the URL branch (line 140) compare case-insensitively against $GITHUB_REPOSITORY and re-route to same-repo so side effects still run. ✅
  • The same-repo regex is byte-identical to the pre-PR version and all cross-repo branches are purely additive, so regression risk on the existing Fixes #N path is minimal. The downstream side-effect steps (comment on issue, #N body-patch) are correctly gated with is_cross_repo != 'true' (lines 362, 378, 455, 462, 475).

I confirmed the var=$(… | grep …) no-match pattern (e.g. line 299, 324) does not abort under GitHub's default set -eo pipefail — the pre-existing team-label friendly-error path relies on exactly this and works, so the new grep-assignments inherit the same safe behavior.

New Issues

  • 🟡 Medium: .github/workflows/issue_comp_link-issue-to-pr.yml:298-307 — the cross-repo label check swallows every gh issue view failure as "implicit approval". A typo'd or nonexistent reference like Fixes dotCMS/typo-repo#999 fails the fetch and passes the check with zero validation, indistinguishable from a genuine private-repo 403. Since the whole point of this workflow is to guarantee a real linked issue, consider distinguishing 404/not-found (fail) from 403/forbidden (pass). At minimum the current behavior means the "linked issue exists" guarantee is best-effort for cross-repo refs — acceptable if intentional, but worth calling out. Fix this →

  • 🟡 Medium: .github/workflows/issue_comp_link-issue-to-pr.yml:105-106 — the cross-repo pattern [a-zA-Z0-9_.-]+/[a-zA-Z0-9_.-]+#[0-9]+ can false-positive on non-repo text after a keyword, e.g. Fixes utils/helper#2 or Closes path/to#5. Because same-repo #N is checked first, this only bites when the body has no plain #N but does contain a word/word#num token — a real issue would then be misread as cross-repo and its same-repo side effects skipped. Assumption: such tokens are rare in PR bodies. What to verify: whether any existing PR templates or common phrasings produce word/word#digits. Low likelihood; flagging for awareness, not blocking.

Both items are non-blocking. No 🔴/🟠 issues — the change is safe to merge from a correctness standpoint.
ci/link-issue-cross-repo-support

@mbiuki
mbiuki enabled auto-merge July 7, 2026 19:52
@mbiuki

mbiuki commented Jul 7, 2026

Copy link
Copy Markdown
Member Author

Hey @nollymar — since you introduced and hardened this workflow (dc5ec7d), tagging you for review on this one. The fix adds support for cross-repo issue references (owner/repo#N and full GitHub URLs) so PRs tracking work in private repos don't fail the check. Would love your eyes on the detection logic and the downstream step conditions.

@mbiuki mbiuki moved this to In Review in dotCMS - Product Planning Jul 7, 2026
@mbiuki mbiuki added the Team : Security Issues related to security and privacy label Jul 7, 2026
… workflow

- Move same-repo `#N` check before cross-repo patterns so an explicit
  `Fixes #123` is never shadowed by a stray `word/word#N` elsewhere in
  the body
- After extracting owner/repo from a cross-repo match, compare
  case-insensitively to `$GITHUB_REPOSITORY`; route as same-repo when
  they match, so `Fixes #123` doesn't skip same-repo side
  effects on its own repo

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JHg1W7beD4Z1yLoTJpyXss
@mbiuki

mbiuki commented Jul 7, 2026

Copy link
Copy Markdown
Member Author

@nollymar The two issues flagged in the AI review are now fixed (commit 642ca0c). When you get a chance, could you take another look? Summary of what changed:

  1. Priority — same-repo #N is now checked first, so Fixes #123 can't be shadowed by a stray owner/repo#N elsewhere in the body.
  2. Self-reference — after extracting the owner/repo from a cross-repo match, we now compare it case-insensitively to $GITHUB_REPOSITORY; if they match it routes as same-repo so all side effects still run.

Thanks!

@mbiuki

mbiuki commented Jul 13, 2026

Copy link
Copy Markdown
Member Author

@nollymar Gentle ping — this one is blocking PR #36344 from merging. Both fixes from the AI review are in (commit 642ca0c). Would appreciate a review when you have a moment. Thanks!

@mbiuki
mbiuki added this pull request to the merge queue Jul 14, 2026
@mergify

mergify Bot commented Jul 14, 2026

Copy link
Copy Markdown

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

Merged via the queue into main with commit 1d01700 Jul 14, 2026
40 checks passed
@mbiuki
mbiuki deleted the ci/link-issue-cross-repo-support branch July 14, 2026 23:01
@mbiuki mbiuki moved this from In Review to Done in dotCMS - Product Planning Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI: Safe To Rollback Area : CI/CD PR changes GitHub Actions/workflows Team : Security Issues related to security and privacy

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

ci: link-issue check fails for cross-repo and private issue references

2 participants