[CI] Require an upstream decision on PRs to release branches #4006
<!-- rocm-security-gh:pr-findings:v1 -->
<details>
<summary><b>Security scan found no critical or high findings on lines changed by this pull request</b></summary>
View the security scan run for complete reports.
_“New” means the finding is located in a changed file on an added or modified line; it is not a base-versus-head findings delta._
</details>
@haribabug Can you please let us know if you have any concerns on this commit of this PR: https://github.com/ROCm/pytorch/pull/4006/changes/95abf7d146706218d88bb12efc059b6c2797bca0? We are trying to set up a flow that comments on the PR if the user needs to take action.
@haribabug Can you please let us know if you have any concerns on this commit of this PR: 95abf7d? We are trying to set up a flow that comments on the PR if the user needs to take action.
@jithunnair-amd Reviewed. No concerns with the current implementation. The pull_request_target workflow only processes PR metadata/API operations, and the Zizmor suppression is scoped to dangerous-triggers. Please maintain this trust boundary and do not introduce checkout or execution of PR-controlled code or artifacts without a security review.
Approved these changes.
cgoea
pablo-garay
Linked issue or supporting maintainer
Part of AIPYTORCH-1303 (design reviewed and approved by the team).
BC-breaking?
No
Summary (human written only)
Adds an
upstream-pr-checkjob on PRs torelease/*. It passes when the description references the upstream PR (pytorch/pytorch#12345or agithub.com/pytorch/pytorch/pull/...link) or the PR has the newno-upstreamlabel for ROCm-only changes. Otherwise it fails and keeps one comment on the PR explaining how to pass; it re-runs when the description or labels change. It only reads the event payload and never checks out PR code, sopull_request_targetis safe. This is the advisory phase: nothing blocks merges until arelease/ruleset requiresupstream-pr-check. Becausepull_request_targetloads the workflow from the base branch, the same file also goes torelease/2.15in #4007; future release branches pick it up fromdevelopand the release carry-forward.Tested with
actionlint, and by running the script against mocks for every pass/fail and comment path, and against the last 15 mergedrelease/2.15PRs (8 pass, 7 would need a link or the label).Demo
Running in pablo-garay/upstream-pr-check-demo, which has the same branch layout:
!Demo PR list: #1 fails, #2 to #5 pass
No upstream decision recorded (#1): the check fails and the bot explains how to pass.
!Demo PR #1: failing check and bot comment
Upstream PR referenced in the description (#2): the check passes.
!Demo PR #2: passing with an upstream link
ROCm fork-only change with the
no-upstreamlabel (#3): the check passes.!Demo PR #3: passing with the no-upstream label
Fixed by adding the upstream link to the description (#4): the check re-runs and the same comment flips to passing.
!Demo PR #4: passing after the description was edited