Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
tag

GitHub Action

Label Commenter

v1.8.0

Label Commenter Action

Label Commenter Action thumbnail

license release GitHub release date Release Feed

This action is one of label triggered GitHub Actions for posting a template message. After commenting, it can automatically close or reopen issues. Of course, it also can manage pull requests.

This Action was submitted to the GitHub Actions Hackathon and featured by GitHub. (Featured actions from the GitHub Actions Hackathon - The GitHub Blog)

Table of Contents

Table of Contents are generated with DocToc

Getting Started

Create your GitHub Actions workflow file and Label Commenter Action setting file. Commit those and push to the remote default branch.

Workflow Setting

# .github/workflows/label-commenter.yml

name: Label Commenter

on:
  issues:
    types:
      - labeled
      - unlabeled
  pull_request_target:
    types:
      - labeled
      - unlabeled

jobs:
  comment:
    runs-on: ubuntu-18.04
    steps:
      - uses: actions/checkout@v2
        with:
          ref: main

      - name: Label Commenter
        uses: peaceiris/actions-label-commenter@v1
        # with:
          # config_file: .github/label-commenter-config.yml

Action Setting

# .github/label-commenter-config.yml

labels:
  - name: invalid
    labeled:
      issue:
        body: Please follow the issue templates.
        action: close
      pr:
        body: Thank you @{{ pull_request.user.login }} for suggesting this. Please follow the pull request templates.
        action: close
    unlabeled:
      issue:
        body: Thank you for following the template. The repository owner will reply.
        action: open
  - name: forum
    labeled:
      issue:
        body: |
          Please ask questions about GitHub Actions at the following forum.
          https://github.community/c/github-actions
        action: close
  - name: wontfix
    labeled:
      issue:
        body: This will not be worked on but we appreciate your contribution.
        action: close
    unlabeled:
      issue:
        body: This has become active again.
        action: open
  - name: duplicate
    labeled:
      issue:
        body: This issue already exists.
        action: close
  - name: good first issue
    labeled:
      issue:
        body: This issue is easy for contributing. Everyone can work on this.
  - name: proposal
    labeled:
      issue:
        body: Thank you @{{ issue.user.login }} for suggesting this.

Work with Other Auto Label Actions

Authenticating with the GITHUB_TOKEN - GitHub Docs

When you use the repository's GITHUB_TOKEN to perform tasks on behalf of the GitHub Actions app, events triggered by the GITHUB_TOKEN will not create a new workflow run. This prevents you from accidentally creating recursive workflow runs. For example, if a workflow run pushes code using the repository's GITHUB_TOKEN, a new workflow will not run even when the repository contains a workflow configured to run when push events occur.

You need to provide a personal access token to an auto label GitHub Actions or GitHub Bot like actions/labeler.

- name: Label Commenter
  uses: peaceiris/actions-label-commenter@v1
  with:
    github_token: ${{ secrets.GH_PAT }}

Examples

Comment and Close Invalid Format Issue or Pull Request

Reopen Issue or Pull Request

Comment and Close Wontfix Issue or Pull Request

Comment and Close Duplicate Issue or Pull Request

Comment Multiple Line

Comment and Close Multiple Issues or Pull Requests

Select Label Labeled

Multiple issues will be closed.

Changelog

License

Maintainer