Skip to content

Add target field support to add-labels safe output#1142

Merged
pelikhan merged 5 commits intomainfrom
copilot/fix-a9787627-62d7-4425-8821-eca39103244d
Oct 2, 2025
Merged

Add target field support to add-labels safe output#1142
pelikhan merged 5 commits intomainfrom
copilot/fix-a9787627-62d7-4425-8821-eca39103244d

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Oct 2, 2025

Fixes issue where the target field was not supported for add-labels safe output, unlike add-comment which already had this functionality.

Problem

The add-labels safe output configuration was missing support for the target field, which meant labels could only be added to the triggering issue/PR. The Go code already parsed and passed the target configuration via environment variables, but the JavaScript/TypeScript implementation didn't consume it.

Solution

This PR completes the implementation by adding target field support to the JavaScript/TypeScript code, bringing add-labels to feature parity with add-comment.

The target field now supports three modes:

  • "triggering" (default): Adds labels to the triggering issue/PR
  • "*": Allows adding labels to any issue by specifying issue_number in the agent output
  • Explicit number (e.g., "123"): Adds labels to a specific issue number

Usage Example

safe-outputs:
  add-labels:
    allowed: [bug, enhancement, documentation]
    target: "*"

With this configuration, the agent can add labels to multiple issues in a single workflow run by including issue_number in the output:

# Issue Labeling Agent

Add the label "bug" to issue #1 and the label "documentation" to issue #2.

Changes

  • Updated pkg/workflow/js/add_labels.ts to read and use GITHUB_AW_LABELS_TARGET environment variable
  • Implemented target handling logic consistent with add-comment implementation
  • Added 8 comprehensive tests covering all target scenarios
  • Updated documentation in docs/src/content/docs/reference/safe-outputs.md
  • Created example test workflow demonstrating the feature

Testing

All tests pass including:

  • 43 tests in the add_labels test suite
  • Full unit test suite
  • Linting and TypeScript compilation
  • Example workflow compilation
Original prompt

This section details on the original issue you should resolve

<issue_title>add-labels target not supported</issue_title>
<issue_description>Similar to add-comment, add-labels should support target field</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #1099

💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI and others added 3 commits October 2, 2025 02:12
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] add-labels target not supported Add target field support to add-labels safe output Oct 2, 2025
Copilot AI requested a review from pelikhan October 2, 2025 02:33
@pelikhan pelikhan marked this pull request as ready for review October 2, 2025 02:52
@pelikhan pelikhan merged commit aa154dd into main Oct 2, 2025
12 checks passed
@pelikhan pelikhan deleted the copilot/fix-a9787627-62d7-4425-8821-eca39103244d branch October 2, 2025 03:18
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.

add-labels target not supported

2 participants