Manage labels for issues and pull requests
Important
As of version v2.0.0
, this action has been converted to ESM.
This action can be used to add and remove labels from issues and pull requests.
Here is a simple example of how to use this action in your workflow. Make sure
to replace vX.X.X
with the latest version of this action.
on:
issues:
types:
- opened
jobs:
example:
name: Example
runs-on: ubuntu-latest
# Write permissions to issues is required
permissions:
issues: write
steps:
# Add labels to an issue in this repository
- name: Add Labels
id: add-labels
uses: issue-ops/[email protected]
with:
action: add
issue_number: ${{ github.event.issue.number }}
labels: |
enhancement
great-first-issue
# Remove labels from an issue in this repository
- name: Remove Labels
id: remove-labels
uses: issue-ops/[email protected]
with:
action: remove
issue_number: ${{ github.event.issue.number }}
# Remove these specific labels
labels: |
enhancement
great-first-issue
# Remove labels that match these glob patterns
label_patterns: |
issue-ops-step:*
- When adding labels, if you specify label(s) that do not exist and
create
is set to'false'
(the default), this action will fail. - When removing labels that do not exist, this action will continue without error.
- When removing labels, if you specify a
label_patterns
list, it will match against the existing labels on the issue or PR. If a label matches any of the glob patterns, it will be removed. If no labels match the patterns, no labels will be removed. - The
labels
andlabel_patterns
inputs are not mutually exclusive. If both are specified, the action will remove labels that match the patterns and also remove any labels specified in thelabels
input, regardless of whether they match the patterns.
Input | Default | Description |
---|---|---|
action |
add |
The action (add or remove ) |
create |
'false' |
Create label, if not present |
github_token |
${{ github.token }} |
The GitHub API token to use |
labels |
label1 |
Line-separated label list |
label_patterns |
None | Line-separated list of glob patterns to match when removing labels |
issue_number |
${{ github.event.issue.number }} |
The issue or PR number |
${{ github.event.pull_request.number }} |
||
repository |
${{ github.repository }} |
The repository (owner/repo ) |
api_url |
${{ github.api_url }} |
The GitHub API URL to use |
Warning
If you specify a repository other than the one the action is running in, you
will need to provide a value for the github_token
that has appropriate
permissions (using either a PAT or a GitHub App).