Add remove_label field to label_command to disable automatic label removal#21751
Add remove_label field to label_command to disable automatic label removal#21751
remove_label field to label_command to disable automatic label removal#21751Conversation
…removal Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
remove_label field to label_command to disable automatic label removal
There was a problem hiding this comment.
Pull request overview
Adds a remove_label: false option to the label_command object form to allow workflows to keep the triggering label applied, while avoiding unnecessary write permissions/token scopes when label removal is disabled.
Changes:
- Extended the workflow schema to accept
remove_labelunderon.label_command(object form). - Updated frontmatter extraction +
WorkflowDatato carry aLabelCommandRemoveLabelflag (defaulting totrue). - Adjusted activation job generation to skip the label-removal step and reduce requested permissions when removal is disabled; added tests for default vs disabled behavior.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| pkg/parser/schemas/main_workflow_schema.json | Adds remove_label boolean to the label_command object schema. |
| pkg/workflow/frontmatter_extraction_yaml.go | Extracts remove_label and returns it from extractLabelCommandConfig. |
| pkg/workflow/compiler_types.go | Stores the new LabelCommandRemoveLabel flag in WorkflowData. |
| pkg/workflow/compiler_orchestrator_workflow.go | Wires extracted remove_label into WorkflowData. |
| pkg/workflow/compiler_activation_job.go | Skips remove-label step and prunes permissions/scopes when removal is disabled; sets label_command output fallback. |
| pkg/workflow/label_command_test.go | Adds tests covering remove_label: false and default behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| // When remove_label is disabled, expose the triggering label name directly from the event | ||
| // so downstream jobs can still access it via needs.activation.outputs.label_command. | ||
| outputs["label_command"] = "${{ github.event.label.name }}" |
|
@copilot review comments |
…alse Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Fixed in 278dfba. Instead of the bare Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot the get trigger label name should compute a unified "command_name" output that works for slash_command and label_command. Move logic to JavaScript file, add tests |
…d_name output and tests Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Done in e38d771. Created
The activation job now sets Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
…emove-label-field
…endenciesCompilationWithEnv Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Fixed in b2aab21. The CI failure was Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot merge main |
…emove-label-field # Conflicts: # pkg/workflow/compiler_activation_job.go
Done in 6ac6352. Merged Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Add documentation for the `remove_label` boolean field on the `label_command` trigger (added in #21751). When set to false, the matched label is not removed after activation, making the trigger behave as a persistent state marker rather than a one-shot command. Documents the permission implication: remove_label: false means issues/pull-requests write is not needed for label removal. Updated files: - docs/src/content/docs/reference/triggers.md - docs/src/content/docs/patterns/label-ops.md Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
label_commandalways removes the triggering label — there's no way to keep it. This adds aremove_label: falseoption to the object form that skips label removal and drops the associated write permissions.Changes
main_workflow_schema.json): Addedremove_labelboolean field to thelabel_commandobject formfrontmatter_extraction_yaml.go):extractLabelCommandConfigreturns a third valueremoveLabel bool(defaultstrue)compiler_types.go): AddedLabelCommandRemoveLabel boolfieldcompiler_activation_job.go):remove_trigger_labelstep whenremove_label: falseget_trigger_labelgithub-script step (viaget_trigger_label.cjs) that safely resolves the triggering command name forworkflow_dispatchand non-labeled eventscommand_nameactivation output usable by bothlabel_commandandslash_commandworkflowsGH_AW_MATCHED_COMMANDenv var fromcheck_command_positionwhen the workflow also has aslash_commandtriggerissues:write/discussions:writeand GitHub App token scopes when removal is disabledget_trigger_label.cjs(new): JavaScript file implementing the label/command name resolution logic, outputting bothlabel_nameand a unifiedcommand_nameget_trigger_label.test.cjs(new): Tests covering labeled events (issues, PR, discussion),workflow_dispatch, slash-command context, and precedence rulesExample
Downstream jobs can access
${{ needs.activation.outputs.command_name }}regardless of whether the workflow was triggered by a label or a slash command.Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.