Skip to content

feat(action): add optional pr_number input and workflow_run fallback - #1156

Open
ylcn91 wants to merge 2 commits into
alibaba:mainfrom
ylcn91:feat/action-pr-number-input
Open

feat(action): add optional pr_number input and workflow_run fallback#1156
ylcn91 wants to merge 2 commits into
alibaba:mainfrom
ylcn91:feat/action-pr-number-input

Conversation

@ylcn91

@ylcn91 ylcn91 commented Sep 3, 2026

Copy link
Copy Markdown

Description

On workflow_run the action found no pull request number. The fetch step read github.event.pull_request.number || github.event.issue.number and the range and posting steps read context.issue.number; none of them resolve for that event, whose payload names the pull request only under workflow_run.pull_requests[0]. The review ran to completion, the posting step requested /repos/OWNER/REPO/issues//comments, got a 404, and the findings were lost.

A new "Resolve PR refs" step resolves the number once, in this order: the new optional pr_number input, then the event payload, then workflow_run.pull_requests[0].number. It publishes the value as $PR_NUMBER and fails right there, before OCR is installed or any LLM quota is spent, when nothing resolves or the value is not a PR number. The head fetch, the checkpoint resolver and the posting step all read that one value; runPostReviewComments takes it as an option and still falls back to context.issue.number when a caller omits it.

pull_request, pull_request_target and issue_comment behave as before: an unset input falls through to the existing resolution.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Refactoring (no functional changes)
  • Documentation update
  • CI / Build / Tooling

How Has This Been Tested?

  • make test passes locally

  • Manual testing (describe below)

  • npm run test:github-actions: new action-contract cases cover the resolution order, the workflow_run fallback, the early failure on a missing or non-numeric value, and the prNumber option of runPostReviewComments together with its existing context.issue.number fallback.

  • make test on this branch (Go packages plus the node script tests).

  • Only action.yml, the scripts under scripts/github-actions/ and examples/github_actions/README.md change; there is no Go change.

Checklist

  • My code follows the project's coding style (go fmt, go vet)
  • I have performed a self-review of my code
  • I have added tests that prove my fix is effective or my feature works
  • New and existing unit tests pass locally with my changes
  • I have updated the documentation accordingly (if applicable)
  • I have signed the CLA

Related Issues

Closes #1150

@CLAassistant

CLAassistant commented Sep 3, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

🔍 OpenCodeReview found 1 issue(s) in this PR.

  • ✅ Successfully posted inline: 1 comment(s)

Comment thread scripts/github-actions/post-review-comments.js Outdated
The pull request number was read from the event payload in two places: the
fetch step's `github.event.pull_request.number || github.event.issue.number`,
and `context.issue.number` in the range and posting steps. Neither resolves on
`workflow_run`, whose payload names the pull request only under
`workflow_run.pull_requests[0]`. The review therefore ran to completion and the
posting step then requested /repos/OWNER/REPO/issues//comments, got a 404, and
the findings were lost.

"Resolve PR refs" now resolves the number once — the new optional `pr_number`
input, then the event payload, then `workflow_run.pull_requests[0].number` —
publishes it as $PR_NUMBER, and fails there when nothing resolves or the value
is not a PR number, before OCR is installed or any LLM quota is spent. The head
fetch, the checkpoint resolver and the posting step all read that one value;
runPostReviewComments takes it as an option and still falls back to
context.issue.number when a caller omits it.

Behavior is unchanged for pull_request, pull_request_target and issue_comment:
an unset input falls through to the existing resolution.

Closes alibaba#1150
The review guidelines rule out loose equality, so spell out the null and undefined checks that `!= null` covered.
@ylcn91
ylcn91 force-pushed the feat/action-pr-number-input branch from efa02a1 to b30dd5c Compare September 7, 2026 06:25
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.

feat(action): optional pr_number input, for triggers that carry no pull request

2 participants