Skip to content

feat(output): add number and context outputs, soft-deprecate issue_number #100

Closed

Description

@wadackel

Summary

Extend outputs so consumers can:

  1. Read the issue/PR number from a new generic field named number (rather than issue_number).
  2. Detect the triggering context (issue vs pull_request) from a new context output that mirrors the allowed_contexts input 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_number is 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 that issue_number also carries the PR number — which is non-obvious.
  • The action already accepts an allowed_contexts input with values issue / pull_request, but there is no output that tells downstream steps which of the two actually triggered the run. Today this requires recomputing context.payload.issue.pull_request != null in user-side script. Exposing it as context removes that duplication.
  • Renaming via a parallel field keeps v1 fully backward compatible.

Proposed changes

1. Add number output

  • Add a new output number that emits the value currently emitted by issue_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_number with the same value as today.
  • Update its description in action.yaml to be prefixed with [Deprecated] and to recommend number.
  • 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 context whose value is "issue" or "pull_request".
  • Determination rule: "pull_request" if context.payload.issue.pull_request != null, else "issue". The existing isPr calculation in isValidContext (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 isValidContext passes, additionally set:
    • core.setOutput('number', context.payload.issue!.number!);
    • core.setOutput('context', isPr ? 'pull_request' : 'issue');
  • isPr should be lifted out of isValidContext (or both call sites should call a shared helper) to keep a single source of truth.

README

  • Update the Outputs table to include number and context.
  • Mark issue_number as deprecated and link to number.

Acceptance criteria

  • action.yaml declares number and context outputs with descriptions above.
  • action.yaml description of issue_number is prefixed with [Deprecated] and recommends number.
  • src/main.ts emits number, context, and continues to emit issue_number with the same value as today.
  • number === issue_number for both issue and pull_request contexts.
  • context === "pull_request" when the comment is on a PR, otherwise "issue".
  • When isValidContext returns false, none of number / context / issue_number are emitted (matches current issue_number behavior).
  • pnpm build produces an updated dist/, committed in the same PR.
  • pnpm generate is 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_contexts to 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.md is regenerated by pnpm generate; if not, it must be edited by hand. Confirm during implementation.
  • Naming the new output context is acceptable even though context is also the conventional name of the @actions/github context 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 — current issue_number and command outputs.
  • src/main.ts:26 — current isPr computation.
  • src/main.ts:58-60 — current output emission site for issue_number / comment_id / actor.
  • README §Outputs.

Activity

  1. github-actions commented on May 16, 2026

    @github-actions

    🎉 This issue has been resolved in version 2.1.0 🎉

    The release is available on GitHub release

    Your semantic-release bot 📦🚀

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions