mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-05-05 21:54:50 +00:00
refactor: extract shared resolve-pr-from-workflow-run action (#11336)
## Summary Extract duplicated PR-number-resolution logic from `workflow_run`-triggered workflows into a shared composite action at `.github/actions/resolve-pr-from-workflow-run/`. ## Changes - **What**: New composite action that resolves PR number from `workflow_run` context using `pull_requests[0]` with `listPullRequestsAssociatedWithCommit` fallback. Updated 4 consumer workflows; removed dead artifact-stored PR metadata from 2 CI workflows. - **Files touched**: - `.github/actions/resolve-pr-from-workflow-run/action.yaml` (new) - `.github/workflows/pr-vercel-website-preview.yaml` (uses shared action) - `.github/workflows/pr-report.yaml` (uses shared action with `check-staleness: true`) - `.github/workflows/ci-tests-storybook-forks.yaml` (replaced `pulls.list` scan) - `.github/workflows/ci-tests-e2e-forks.yaml` (replaced `pulls.list` scan) - `.github/workflows/ci-size-data.yaml` (removed dead `number.txt`/`base.txt`/`head-sha.txt` writes) - `.github/workflows/ci-perf-report.yaml` (removed dead `perf-meta` artifact) ## Review Focus - The fork workflows previously used `pulls.list` (fetches all open PRs, linear scan by SHA). The shared action uses the more targeted `workflow_run.pull_requests[0]` + `listPullRequestsAssociatedWithCommit` fallback. - `coverage-slack-notify.yaml` was intentionally left unchanged — it parses merged commit messages on `main` pushes, which is a different use case. ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-11336-refactor-extract-shared-resolve-pr-from-workflow-run-action-3456d73d365081e5b8f5ea29c020763e) by [Unito](https://www.unito.io) --------- Co-authored-by: bymyself <cbyrne@comfy.org> Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
37
.github/workflows/pr-report.yaml
vendored
37
.github/workflows/pr-report.yaml
vendored
@@ -30,42 +30,7 @@ jobs:
|
||||
|
||||
- name: Resolve PR from workflow_run context
|
||||
id: pr-meta
|
||||
uses: actions/github-script@v8
|
||||
with:
|
||||
script: |
|
||||
let pr = context.payload.workflow_run.pull_requests?.[0];
|
||||
if (!pr) {
|
||||
const { data: prs } = await github.rest.repos.listPullRequestsAssociatedWithCommit({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
commit_sha: context.payload.workflow_run.head_sha,
|
||||
});
|
||||
pr = prs.find(p => p.state === 'open');
|
||||
}
|
||||
|
||||
if (!pr) {
|
||||
core.info('No open PR found for this workflow run — skipping.');
|
||||
core.setOutput('skip', 'true');
|
||||
return;
|
||||
}
|
||||
|
||||
// Verify the workflow_run head SHA matches the current PR head
|
||||
const { data: livePr } = await github.rest.pulls.get({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
pull_number: pr.number,
|
||||
});
|
||||
|
||||
if (livePr.head.sha !== context.payload.workflow_run.head_sha) {
|
||||
core.info(`Stale run: workflow SHA ${context.payload.workflow_run.head_sha} != PR head ${livePr.head.sha}`);
|
||||
core.setOutput('skip', 'true');
|
||||
return;
|
||||
}
|
||||
|
||||
core.setOutput('skip', 'false');
|
||||
core.setOutput('number', String(pr.number));
|
||||
core.setOutput('base', livePr.base.ref);
|
||||
core.setOutput('head-sha', livePr.head.sha);
|
||||
uses: ./.github/actions/resolve-pr-from-workflow-run
|
||||
|
||||
- name: Find size workflow run
|
||||
if: steps.pr-meta.outputs.skip != 'true'
|
||||
|
||||
Reference in New Issue
Block a user