3.6 KiB
title, intro, redirect_from, versions, type, topics
| title | intro | redirect_from | versions | type | topics | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Adding labels to issues | You can use {% data variables.product.prodname_actions %} to automatically label issues. |
|
|
tutorial |
|
{% data reusables.actions.enterprise-beta %} {% data reusables.actions.enterprise-github-hosted-runners %}
Introduction
This tutorial demonstrates how to use the andymckay/labeler action in a workflow to label newly opened or reopened issues. For example, you can add the triage label every time an issue is opened or reopened. Then, you can see all issues that need to be triaged by filtering for issues with the triage label.
In the tutorial, you will first make a workflow file that uses the andymckay/labeler action. Then, you will customize the workflow to suit your needs.
Creating the workflow
-
{% data reusables.actions.choose-repo %}
-
{% data reusables.actions.make-workflow-file %}
-
Copy the following YAML contents into your workflow file.
{% indented_data_reference reusables.actions.actions-not-certified-by-github-comment spaces=4 %}
name: Label issues
on:
issues:
types:
- reopened
- opened
jobs:
label_issues:
runs-on: ubuntu-latest{% ifversion fpt or ghes > 3.1 or ghae or ghec %}
permissions:
issues: write{% endif %}
steps:
- name: Label issues
uses: andymckay/labeler@e6c4322d0397f3240f0e7e30a33b5c5df2d39e90
with:
add-labels: "triage"
repo-token: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %}
```
- Customize the parameters in your workflow file:
- Change the value for
add-labelsto the list of labels that you want to add to the issue. Separate multiple labels with commas. For example,"help wanted, good first issue". For more information about labels, see "Managing labels."
- Change the value for
- {% data reusables.actions.commit-workflow %}
Testing the workflow
Every time an issue in your repository is opened or reopened, this workflow will add the labels that you specified to the issue.
Test out your workflow by creating an issue in your repository.
- Create an issue in your repository. For more information, see "Creating an issue."
- To see the workflow run that was triggered by creating the issue, view the history of your workflow runs. For more information, see "Viewing workflow run history."
- When the workflow completes, the issue that you created should have the specified labels added.
Next steps
- To learn more about additional things you can do with the
andymckay/labeleraction, like removing labels or skipping this action if the issue is assigned or has a specific label, see theandymckay/labeleraction documentation. - To learn more about different events that can trigger your workflow, see "Events that trigger workflows." The
andymckay/labeleraction only works onissues,pull_request, orproject_cardevents. - Search GitHub for examples of workflows using this action.