Skip to content

fix(CI): pass PR number as artifact instead of resolving it from workflow_run - #12656

Open
dlabaj wants to merge 1 commit into
mainfrom
fix/12655-documentation-deploy-pr-resolution
Open

dlabaj wants to merge 1 commit into
mainfrom
fix/12655-documentation-deploy-pr-resolution

Conversation

@dlabaj

@dlabaj dlabaj commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Summary

  • documentation-deploy.yml's Resolve PR number step falls back to GET /repos/{owner}/{repo}/commits/{sha}/pulls whenever workflow_run.pull_requests is empty — which GitHub leaves empty for every fork PR by design (only populated when the PR's head branch is in the same repo as the base).
  • That fallback doesn't reliably resolve fork-only commits either. I confirmed this directly against PR fix(docked nav): persistent inline nav #12653's head commits, both via the REST endpoint the workflow uses and via the GraphQL associatedPullRequests field — both return zero results, even a day after the run, so it isn't a transient indexing delay.
  • As a result every fork PR deploy fails at Resolve PR number, and the only working path is a manual /deploy-preview comment.

Fix

  • documentation.yml now saves github.event.pull_request.number to a file and uploads it as a pr-number artifact on the pull_request event, alongside the existing documentation and a11y-coverage artifacts.
  • documentation-deploy.yml downloads that artifact and reads the PR number from it instead of trying to reverse-engineer it from the API afterward.

This value comes from github.event.pull_request.number, a field GitHub populates from the actual event metadata before the job's shell runs — it isn't influenced by anything in the PR's checked-out code, so it carries the same trust level as the documentation/a11y-coverage artifacts already produced by this job.

Note: an earlier version of this same split (#12625) used this exact solution, and it was replaced with the current API-lookup approach after a CodeRabbit review flagged the artifact as "untrusted." Having now confirmed the API-lookup path is fundamentally broken for fork PRs (not just under-hardened), and that the artifact's content isn't attacker-influenceable, this PR adds back the original solution. If CodeRabbit flags this again we should ignore it's suggestion.

Closes #12655

🤖 Claude Code assisted in the solution for this issue.

Summary by CodeRabbit

  • Chores
    • Improved documentation deployment handling for pull requests.
    • Documentation builds now retain the associated pull request information more consistently, supporting more reliable preview and deployment workflows.

…flow_run

documentation-deploy.yml resolved the originating PR by falling back to
GET /repos/{owner}/{repo}/commits/{sha}/pulls when workflow_run.pull_requests
was empty, which GitHub leaves empty for every fork PR by design. That
fallback itself doesn't reliably index fork-only commits either (confirmed
empty via both REST and GraphQL for PR #12653's commits), so every fork PR
deploy failed at Resolve PR number.

Have documentation.yml save github.event.pull_request.number as its own
artifact on the pull_request event (a value provided by GitHub, not
influenced by the PR's contents) and have documentation-deploy.yml read it
back instead of trying to look the PR up after the fact.

Fixes #12655

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 17, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 1e376119-7aba-4ac5-9d4f-7d90098113d3

📥 Commits

Reviewing files that changed from the base of the PR and between d922b9c and 25d9ecd.

📒 Files selected for processing (2)
  • .github/workflows/documentation-deploy.yml
  • .github/workflows/documentation.yml

Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review.


Walkthrough

The documentation workflow now uploads the pull request number as an artifact. The deployment workflow downloads and validates that value instead of resolving the pull request through workflow metadata or commit-based GitHub API queries.

Changes

Documentation Preview PR Tracking

Layer / File(s) Summary
Create pull request number artifact
.github/workflows/documentation.yml
For pull request events, the workflow writes github.event.pull_request.number to pr_number.txt and uploads it as the pr-number artifact.
Consume pull request number artifact
.github/workflows/documentation-deploy.yml
The deployment workflow removes pull-requests: read, downloads the pr-number artifact, reads pr_number.txt, and retains numeric validation of PR_NUM.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Sequence Diagram(s)

sequenceDiagram
  participant DocumentationWorkflow
  participant ArtifactStorage
  participant DocumentationDeploy
  DocumentationWorkflow->>ArtifactStorage: Upload pr-number artifact
  DocumentationDeploy->>ArtifactStorage: Download pr-number artifact
  ArtifactStorage-->>DocumentationDeploy: Return pr_number.txt
  DocumentationDeploy->>DocumentationDeploy: Read and validate PR_NUM
Loading

Merge Risk: ⚪ Minimal · up to 25d9e

The documentation preview workflow preserves the PR number for both fork and same-repository pull requests, with no actionable merge-blocking risk identified.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Issue #12655 requires the Documentation workflow to preserve the PR number and the Documentation deploy workflow to consume it. .github/workflows/documentation.yml writes `github.event.pull_request.…
Out of Scope Changes check ✅ Passed The changes are limited to the two workflows named by Issue #12655. They add the PR-number artifact, consume it during deployment, and remove the obsolete PR lookup and permission. No unrelated source…
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: passing the pull request number as an artifact instead of resolving it from workflow data.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/12655-documentation-deploy-pr-resolution

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@patternfly-build

patternfly-build commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deploy fails on fork repo

2 participants