Skip to content

Fix preview-publish PR lookup for fork PRs - #3695

Merged
jodeleeuw merged 1 commit into
mainfrom
fix/preview-publish-fork-pr-lookup
Jun 26, 2026
Merged

Fix preview-publish PR lookup for fork PRs#3695
jodeleeuw merged 1 commit into
mainfrom
fix/preview-publish-fork-pr-lookup

Conversation

@jodeleeuw

Copy link
Copy Markdown
Member

Problem

Fork PRs (e.g. #3694) never receive a preview-build comment. The preview-build workflow succeeds and uploads the artifact, but the companion preview-publish workflow — which runs in the trusted base-repo context and is responsible for pushing the preview branch and posting the comment — fails early:

##[error]No open PR found for head SHA b57950b961b6cf7e4d6a1c2ba8f515e7a582a3a4

Root cause

For fork PRs, workflow_run.pull_requests is empty (as the workflow already anticipates), so it falls back to listPullRequestsAssociatedWithCommit. But that endpoint returns [] for a fork-PR head commit, because the commit doesn't live in a base-repo branch — only under refs/pull/N/head. With no match, the step calls core.setFailed(...) and the job dies before commenting.

Verified directly against the API for #3694's head SHA:

repos/jspsych/jsPsych/commits/b57950b.../pulls  ->  []

Fix

Look the PR up by its head ref (headOwner:headBranch) — both taken from the trusted workflow_run payload — via pulls.list. This resolves the PR where the previous approach returned nothing:

pulls?state=open&head=htsukamoto5:multiplayer  ->  { number: 3694, head_sha: b57950b..., state: open }

Trust guarantees are unchanged: the PR number and head SHA are still sourced only from the trusted event payload and validated downstream (the artifact's self-reported SHA/number are still cross-checked against these values). Same-repo PRs are unaffected — they populate workflow_run.pull_requests and never hit the fallback. A stale build (head moved after the build started) still correctly fails, since the match requires p.head.sha === headSha.

Verification note

workflow_run always runs the workflow version on the base branch, so this can only be fully validated after merge: once on main, retriggering preview-build on a fork PR (e.g. push a commit to #3694) should make the publish job resolve the PR and post the preview comment.

🤖 Generated with Claude Code

@changeset-bot

changeset-bot Bot commented Jun 26, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 5729107

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

The fork-PR fallback used listPullRequestsAssociatedWithCommit, which
returns an empty list for fork-PR head commits (they don't live in a
base-repo branch). The publish job therefore failed with "No open PR
found" before it could push the preview branch or post the comment, so
fork PRs (e.g. #3694) never received a preview comment.

Look the PR up by its head ref (headOwner:headBranch) from the trusted
workflow_run payload via pulls.list instead. The PR number and head SHA
are still sourced only from the trusted event payload and validated
downstream, so trust guarantees are unchanged.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@jodeleeuw
jodeleeuw force-pushed the fix/preview-publish-fork-pr-lookup branch from 3d5d39d to 5729107 Compare June 26, 2026 15:06
@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

📦 Preview build ready

Built from PR head 5729107 and published at e28294c on branch preview/pr-3695.
URLs below are pinned to an immutable commit SHA, so they are safe to share and are cached permanently by jsDelivr.

Changed packages: none detected

Quick-start HTML:

<script src="https://cdn.jsdelivr.net/gh/jspsych/jsPsych@e28294c10b69f91f3b5173b5e8ac4f081476b754/packages/jspsych/dist/index.browser.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/jspsych/jsPsych@e28294c10b69f91f3b5173b5e8ac4f081476b754/packages/jspsych/css/jspsych.css">
<script src="https://cdn.jsdelivr.net/gh/jspsych/jsPsych@e28294c10b69f91f3b5173b5e8ac4f081476b754/packages/plugin-html-keyboard-response/dist/index.browser.min.js"></script>
All package URLs
  • @jspsych/extension-mouse-trackinghttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@e28294c10b69f91f3b5173b5e8ac4f081476b754/packages/extension-mouse-tracking/dist/index.browser.min.js
  • @jspsych/extension-record-videohttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@e28294c10b69f91f3b5173b5e8ac4f081476b754/packages/extension-record-video/dist/index.browser.min.js
  • @jspsych/extension-webgazerhttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@e28294c10b69f91f3b5173b5e8ac4f081476b754/packages/extension-webgazer/dist/index.browser.min.js
  • jspsychhttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@e28294c10b69f91f3b5173b5e8ac4f081476b754/packages/jspsych/dist/index.browser.min.js
  • @jspsych/plugin-animationhttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@e28294c10b69f91f3b5173b5e8ac4f081476b754/packages/plugin-animation/dist/index.browser.min.js
  • @jspsych/plugin-audio-button-responsehttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@e28294c10b69f91f3b5173b5e8ac4f081476b754/packages/plugin-audio-button-response/dist/index.browser.min.js
  • @jspsych/plugin-audio-keyboard-responsehttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@e28294c10b69f91f3b5173b5e8ac4f081476b754/packages/plugin-audio-keyboard-response/dist/index.browser.min.js
  • @jspsych/plugin-audio-slider-responsehttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@e28294c10b69f91f3b5173b5e8ac4f081476b754/packages/plugin-audio-slider-response/dist/index.browser.min.js
  • @jspsych/plugin-browser-checkhttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@e28294c10b69f91f3b5173b5e8ac4f081476b754/packages/plugin-browser-check/dist/index.browser.min.js
  • @jspsych/plugin-call-functionhttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@e28294c10b69f91f3b5173b5e8ac4f081476b754/packages/plugin-call-function/dist/index.browser.min.js
  • @jspsych/plugin-canvas-button-responsehttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@e28294c10b69f91f3b5173b5e8ac4f081476b754/packages/plugin-canvas-button-response/dist/index.browser.min.js
  • @jspsych/plugin-canvas-keyboard-responsehttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@e28294c10b69f91f3b5173b5e8ac4f081476b754/packages/plugin-canvas-keyboard-response/dist/index.browser.min.js
  • @jspsych/plugin-canvas-slider-responsehttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@e28294c10b69f91f3b5173b5e8ac4f081476b754/packages/plugin-canvas-slider-response/dist/index.browser.min.js
  • @jspsych/plugin-categorize-animationhttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@e28294c10b69f91f3b5173b5e8ac4f081476b754/packages/plugin-categorize-animation/dist/index.browser.min.js
  • @jspsych/plugin-categorize-htmlhttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@e28294c10b69f91f3b5173b5e8ac4f081476b754/packages/plugin-categorize-html/dist/index.browser.min.js
  • @jspsych/plugin-categorize-imagehttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@e28294c10b69f91f3b5173b5e8ac4f081476b754/packages/plugin-categorize-image/dist/index.browser.min.js
  • @jspsych/plugin-clozehttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@e28294c10b69f91f3b5173b5e8ac4f081476b754/packages/plugin-cloze/dist/index.browser.min.js
  • @jspsych/plugin-external-htmlhttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@e28294c10b69f91f3b5173b5e8ac4f081476b754/packages/plugin-external-html/dist/index.browser.min.js
  • @jspsych/plugin-free-sorthttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@e28294c10b69f91f3b5173b5e8ac4f081476b754/packages/plugin-free-sort/dist/index.browser.min.js
  • @jspsych/plugin-fullscreenhttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@e28294c10b69f91f3b5173b5e8ac4f081476b754/packages/plugin-fullscreen/dist/index.browser.min.js
  • @jspsych/plugin-html-audio-responsehttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@e28294c10b69f91f3b5173b5e8ac4f081476b754/packages/plugin-html-audio-response/dist/index.browser.min.js
  • @jspsych/plugin-html-button-responsehttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@e28294c10b69f91f3b5173b5e8ac4f081476b754/packages/plugin-html-button-response/dist/index.browser.min.js
  • @jspsych/plugin-html-keyboard-responsehttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@e28294c10b69f91f3b5173b5e8ac4f081476b754/packages/plugin-html-keyboard-response/dist/index.browser.min.js
  • @jspsych/plugin-html-slider-responsehttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@e28294c10b69f91f3b5173b5e8ac4f081476b754/packages/plugin-html-slider-response/dist/index.browser.min.js
  • @jspsych/plugin-html-video-responsehttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@e28294c10b69f91f3b5173b5e8ac4f081476b754/packages/plugin-html-video-response/dist/index.browser.min.js
  • @jspsych/plugin-iat-htmlhttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@e28294c10b69f91f3b5173b5e8ac4f081476b754/packages/plugin-iat-html/dist/index.browser.min.js
  • @jspsych/plugin-iat-imagehttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@e28294c10b69f91f3b5173b5e8ac4f081476b754/packages/plugin-iat-image/dist/index.browser.min.js
  • @jspsych/plugin-image-button-responsehttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@e28294c10b69f91f3b5173b5e8ac4f081476b754/packages/plugin-image-button-response/dist/index.browser.min.js
  • @jspsych/plugin-image-keyboard-responsehttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@e28294c10b69f91f3b5173b5e8ac4f081476b754/packages/plugin-image-keyboard-response/dist/index.browser.min.js
  • @jspsych/plugin-image-slider-responsehttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@e28294c10b69f91f3b5173b5e8ac4f081476b754/packages/plugin-image-slider-response/dist/index.browser.min.js
  • @jspsych/plugin-initialize-camerahttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@e28294c10b69f91f3b5173b5e8ac4f081476b754/packages/plugin-initialize-camera/dist/index.browser.min.js
  • @jspsych/plugin-initialize-microphonehttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@e28294c10b69f91f3b5173b5e8ac4f081476b754/packages/plugin-initialize-microphone/dist/index.browser.min.js
  • @jspsych/plugin-instructionshttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@e28294c10b69f91f3b5173b5e8ac4f081476b754/packages/plugin-instructions/dist/index.browser.min.js
  • @jspsych/plugin-maxdiffhttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@e28294c10b69f91f3b5173b5e8ac4f081476b754/packages/plugin-maxdiff/dist/index.browser.min.js
  • @jspsych/plugin-mirror-camerahttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@e28294c10b69f91f3b5173b5e8ac4f081476b754/packages/plugin-mirror-camera/dist/index.browser.min.js
  • @jspsych/plugin-preloadhttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@e28294c10b69f91f3b5173b5e8ac4f081476b754/packages/plugin-preload/dist/index.browser.min.js
  • @jspsych/plugin-reconstructionhttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@e28294c10b69f91f3b5173b5e8ac4f081476b754/packages/plugin-reconstruction/dist/index.browser.min.js
  • @jspsych/plugin-resizehttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@e28294c10b69f91f3b5173b5e8ac4f081476b754/packages/plugin-resize/dist/index.browser.min.js
  • @jspsych/plugin-same-different-htmlhttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@e28294c10b69f91f3b5173b5e8ac4f081476b754/packages/plugin-same-different-html/dist/index.browser.min.js
  • @jspsych/plugin-same-different-imagehttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@e28294c10b69f91f3b5173b5e8ac4f081476b754/packages/plugin-same-different-image/dist/index.browser.min.js
  • @jspsych/plugin-serial-reaction-time-mousehttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@e28294c10b69f91f3b5173b5e8ac4f081476b754/packages/plugin-serial-reaction-time-mouse/dist/index.browser.min.js
  • @jspsych/plugin-serial-reaction-timehttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@e28294c10b69f91f3b5173b5e8ac4f081476b754/packages/plugin-serial-reaction-time/dist/index.browser.min.js
  • @jspsych/plugin-sketchpadhttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@e28294c10b69f91f3b5173b5e8ac4f081476b754/packages/plugin-sketchpad/dist/index.browser.min.js
  • @jspsych/plugin-survey-html-formhttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@e28294c10b69f91f3b5173b5e8ac4f081476b754/packages/plugin-survey-html-form/dist/index.browser.min.js
  • @jspsych/plugin-survey-likerthttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@e28294c10b69f91f3b5173b5e8ac4f081476b754/packages/plugin-survey-likert/dist/index.browser.min.js
  • @jspsych/plugin-survey-multi-choicehttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@e28294c10b69f91f3b5173b5e8ac4f081476b754/packages/plugin-survey-multi-choice/dist/index.browser.min.js
  • @jspsych/plugin-survey-multi-selecthttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@e28294c10b69f91f3b5173b5e8ac4f081476b754/packages/plugin-survey-multi-select/dist/index.browser.min.js
  • @jspsych/plugin-survey-texthttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@e28294c10b69f91f3b5173b5e8ac4f081476b754/packages/plugin-survey-text/dist/index.browser.min.js
  • @jspsych/plugin-surveyhttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@e28294c10b69f91f3b5173b5e8ac4f081476b754/packages/plugin-survey/dist/index.browser.min.js
  • @jspsych/plugin-video-button-responsehttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@e28294c10b69f91f3b5173b5e8ac4f081476b754/packages/plugin-video-button-response/dist/index.browser.min.js
  • @jspsych/plugin-video-keyboard-responsehttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@e28294c10b69f91f3b5173b5e8ac4f081476b754/packages/plugin-video-keyboard-response/dist/index.browser.min.js
  • @jspsych/plugin-video-slider-responsehttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@e28294c10b69f91f3b5173b5e8ac4f081476b754/packages/plugin-video-slider-response/dist/index.browser.min.js
  • @jspsych/plugin-virtual-chinresthttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@e28294c10b69f91f3b5173b5e8ac4f081476b754/packages/plugin-virtual-chinrest/dist/index.browser.min.js
  • @jspsych/plugin-visual-search-circlehttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@e28294c10b69f91f3b5173b5e8ac4f081476b754/packages/plugin-visual-search-circle/dist/index.browser.min.js
  • @jspsych/plugin-webgazer-calibratehttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@e28294c10b69f91f3b5173b5e8ac4f081476b754/packages/plugin-webgazer-calibrate/dist/index.browser.min.js
  • @jspsych/plugin-webgazer-init-camerahttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@e28294c10b69f91f3b5173b5e8ac4f081476b754/packages/plugin-webgazer-init-camera/dist/index.browser.min.js
  • @jspsych/plugin-webgazer-validatehttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@e28294c10b69f91f3b5173b5e8ac4f081476b754/packages/plugin-webgazer-validate/dist/index.browser.min.js

Last updated 2026-06-26 15:09 UTC for PR head 5729107.

github-actions Bot pushed a commit that referenced this pull request Jun 26, 2026
@jodeleeuw
jodeleeuw merged commit e973a8e into main Jun 26, 2026
5 checks passed
@jodeleeuw
jodeleeuw deleted the fix/preview-publish-fork-pr-lookup branch June 26, 2026 15:17
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.

1 participant