Repository navigation
feat(output): add number and context outputs, soft-deprecate issue_number #100
Copy link
Copy link
Closed
Labels
Description
Summary
Extend outputs so consumers can:
- Read the issue/PR number from a new generic field named
number(rather thanissue_number). - Detect the triggering context (issue vs pull_request) from a new
contextoutput that mirrors theallowed_contextsinput vocabulary.
issue_number remains functional in v1 and is marked as deprecated in the description only (soft deprecation). It will be removed in the next major release.
Motivation
issue_numberis misleading on pull-request contexts: GitHub assigns the same number space to issues and pull requests, but the field name implies "issue only". Users invoking the command from a PR comment currently have to recall thatissue_numberalso carries the PR number — which is non-obvious.- The action already accepts an
allowed_contextsinput with valuesissue/pull_request, but there is no output that tells downstream steps which of the two actually triggered the run. Today this requires recomputingcontext.payload.issue.pull_request != nullin user-side script. Exposing it ascontextremoves that duplication. - Renaming via a parallel field keeps v1 fully backward compatible.
Proposed changes
1. Add number output
- Add a new output
numberthat emits the value currently emitted byissue_number. - Source:
context.payload.issue.number. - Semantics: the issue number for an issue context, and the PR number for a pull_request context (i.e., identical to GitHub's own numbering).
2. Soft-deprecate issue_number
- Keep emitting
issue_numberwith the same value as today. - Update its description in
action.yamlto be prefixed with[Deprecated]and to recommendnumber. - No runtime warning is emitted. (Documentation-only deprecation.)
- Removal is scheduled for the next major release; tracked separately (see Out of scope).
3. Add context output
- Add a new output
contextwhose value is"issue"or"pull_request". - Determination rule:
"pull_request"ifcontext.payload.issue.pull_request != null, else"issue". The existingisPrcalculation inisValidContext(src/main.ts:26) is the source of truth — extract it so both call sites use the same logic.
Output emission timing
All three new/changed outputs follow the existing pattern: emitted alongside comment_id / actor / issue_number after isValidContext returns true. This matches the current behavior (these outputs exist when the action proceeds, regardless of whether continue ends up "true" or "false").
Spec details
action.yaml
outputs:
continue: { description: "..." }
params: { description: "..." }
comment_id: { description: "..." }
actor: { description: "..." }
issue_number:
description: '[Deprecated] The issue number of the comment that triggered this action. Use `number` instead. This output will be removed in the next major release.'
number:
description: 'The number of the issue or pull request that triggered this action.'
context:
description: 'The context that triggered this action. One of `"issue"` or `"pull_request"`.'
command: { description: "..." }src/main.ts
- After
isValidContextpasses, additionally set:core.setOutput('number', context.payload.issue!.number!);core.setOutput('context', isPr ? 'pull_request' : 'issue');
isPrshould be lifted out ofisValidContext(or both call sites should call a shared helper) to keep a single source of truth.
README
- Update the Outputs table to include
numberandcontext. - Mark
issue_numberas deprecated and link tonumber.
Acceptance criteria
-
action.yamldeclaresnumberandcontextoutputs with descriptions above. -
action.yamldescription ofissue_numberis prefixed with[Deprecated]and recommendsnumber. -
src/main.tsemitsnumber,context, and continues to emitissue_numberwith the same value as today. -
number === issue_numberfor both issue and pull_request contexts. -
context === "pull_request"when the comment is on a PR, otherwise"issue". - When
isValidContextreturnsfalse, none ofnumber/context/issue_numberare emitted (matches currentissue_numberbehavior). -
pnpm buildproduces an updateddist/, committed in the same PR. -
pnpm generateis run (inputs unchanged, but README Outputs table is regenerated). - Unit/integration tests cover: (a) issue context, (b) pull_request context, (c) invalid context (no new outputs emitted).
- README Outputs table reflects the new fields and the deprecation note.
- No drift: CI checks for
dist/and generated docs pass.
Out of scope
- Removal of
issue_number(tracked for the next major release; create a follow-up issue or milestone). - Emitting a runtime deprecation warning via
core.warning. May be added later if user feedback shows the doc-only deprecation is insufficient. - Exposing additional issue/PR metadata (title, author, labels, etc.). Defer to a separate request.
- Renaming/expanding
allowed_contextsto match a future event-type taxonomy.
Migration
For consumers of v1:
- run: echo "${{ steps.command.outputs.issue_number }}"
+ run: echo "${{ steps.command.outputs.number }}"issue_number continues to work in v1; switch at your own pace.
Assumptions
- The Outputs table in
README.mdis regenerated bypnpm generate; if not, it must be edited by hand. Confirm during implementation. - Naming the new output
contextis acceptable even thoughcontextis also the conventional name of the@actions/githubcontext object in user workflows. Disambiguation lives at the access path (steps.<id>.outputs.context), so no real collision. - "Next major release" is the right horizon for removing
issue_number. No specific timeline is committed.
References
action.yaml:25-28— currentissue_numberandcommandoutputs.src/main.ts:26— currentisPrcomputation.src/main.ts:58-60— current output emission site forissue_number/comment_id/actor.- README §Outputs.
Reactions are currently unavailable
Activity
github-actions commentedon May 16, 2026
🎉 This issue has been resolved in version 2.1.0 🎉
The release is available on GitHub release
Your semantic-release bot 📦🚀