Adding labels to issues

You can use GitHub Actions to automatically label issues.

GitHub Actions ist verfügbar mit GitHub Free, GitHub Pro, GitHub Free für Organisationen, GitHub Team, GitHub Enterprise Cloud, und GitHub AE. GitHub Actions ist nicht verfügbar für private Repositorys, die im Besitz von Konten mit älteren Pro-Repository-Plänen sind. For more information, see "GitHub's products."

Einführung

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

  1. Choose a repository where you want to apply this project management workflow. You can use an existing repository that you have write access to, or you can create a new repository. Weitere Informationen zum Erstellen eines Repositorys findest Du unter „Ein neues Repository erstellen.“

  2. In your repository, create a file called .github/workflows/YOUR_WORKFLOW.yml, replacing YOUR_WORKFLOW with a name of your choice. This is a workflow file. For more information about creating new files on GitHub, see "Creating new files."

  3. Copy the following YAML contents into your workflow file.

    YAML
    name: Label issues
    on:
      issues:
        types:
          - reopened
          - opened
    jobs:
      label_issues:
        runs-on: ubuntu-latest
        permissions:
          issues: write
        steps:
          - name: Label issues
            uses: andymckay/labeler@1.0.2
            with:
              add-labels: "triage"
              repo-token: ${{ secrets.GITHUB_TOKEN }}
  4. Customize the parameters in your workflow file:

    • Change the value for add-labels to 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."
  5. Commit your workflow file to the default branch of your repository. Weitere Informationen finden Sie unter „Neue Dateien erstellen“.

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.

  1. Create an issue in your repository. For more information, see "Creating an issue."
  2. 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."
  3. When the workflow completes, the issue that you created should have the specified labels added.

Nächste Schritte:

  • To learn more about additional things you can do with the andymckay/labeler action, like removing labels or skipping this action if the issue is assigned or has a specific label, see the andymckay/labeler action documentation.
  • To learn more about different events that can trigger your workflow, see "Events that trigger workflows." The andymckay/labeler action only works on issues, pull_request, or project_card events.
  • Search GitHub for examples of workflows using this action.

Did this doc help you?Privacy policy

Help us make these docs great!

All GitHub docs are open source. See something that's wrong or unclear? Submit a pull request.

Make a contribution

Oder, learn how to contribute.