This action is one of label triggered GitHub Actions for posting a template comment, and automatically open/close/lock/unlock issues or 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)
- Getting Started
- Options
- Work with Issue Template
- Work with Other Auto Label Actions
- Examples
- Changelog
- License
- Maintainer
Create your GitHub Actions workflow file and Label Commenter Action setting file. Commit those and push to the remote default branch.
Create your workflow file .github/workflows/label-commenter.yml
as follows.
name: Label Commenter
on:
issues:
types: [labeled, unlabeled]
pull_request_target:
types: [labeled, unlabeled]
permissions:
contents: read
issues: write
pull-requests: write
jobs:
comment:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Label Commenter
uses: peaceiris/actions-label-commenter@v1
Create your action configuration file .github/label-commenter-config.yml
as follows.
comment:
header: Hi, there.
footer: "\
---\n\n\
> This is an automated comment created by the [peaceiris/actions-label-commenter]. \
Responding to the bot or mentioning it won't have any effect.\n\n\
[peaceiris/actions-label-commenter]: https://github.com/peaceiris/actions-label-commenter"
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.
- name: locked (spam)
labeled:
issue:
body: |
This issue has been **LOCKED** because of spam!
Please do not spam messages and/or issues on the issue tracker. You may get blocked from this repository for doing so.
action: close
locking: lock
lock_reason: spam
pr:
body: |
This pull-request has been **LOCKED** because of spam!
Please do not spam messages and/or pull-requests on this project. You may get blocked from this repository for doing so.
action: close
locking: lock
lock_reason: spam
- name: locked (heated)
labeled:
issue:
body: |
This issue has been **LOCKED** because of heated conversation!
We appreciate exciting conversations, as long as they won't become too aggressive and/or emotional.
locking: lock
lock_reason: too heated
pr:
body: |
This pull-request has been **LOCKED** because of heated conversation!
We appreciate exciting conversations, as long as they won't become too aggressive and/or emotional.
locking: lock
lock_reason: too heated
unlabeled:
issue:
body: |
This issue has been unlocked now.
locking: unlock
pr:
body: |
This pull-request has been unlocked now.
locking: unlock
- name: locked (off-topic)
labeled:
issue:
body: |
This issue has been **LOCKED** because of off-topic conversations!
Please use our other means of communication for casual chats.
action: close
locking: lock
lock_reason: off-topic
- name: locked (resolved)
labeled:
issue:
body: |
This issue has been **LOCKED** because of it being resolved!
The issue has been fixed and is therefore considered resolved.
If you still encounter this or it has changed, open a new issue instead of responding to solved ones.
action: close
locking: lock
lock_reason: resolved
Default is .github/label-commenter-config.yml
- name: Label Commenter
uses: peaceiris/actions-label-commenter@v1
with:
config_file: ./path_to/your_config.yml
Default is ${{ github.token }}
- name: Label Commenter
uses: peaceiris/actions-label-commenter@v1
with:
github_token: ${{ secrets.GH_PAT }}
- name: Label Commenter
uses: peaceiris/actions-label-commenter@v1
env:
RUNNER_DEBUG: 1
Here is a proposal issue template: .github/ISSUE_TEMPLATE/3_proposal.yml
name: Proposal
description: Suggest an idea for this project
title: ''
labels: proposal
assignees: peaceiris
body:
...
Scenario:
- When a user opens an issue with the proposal template, the proposal label will be added automatically.
- This action can detect that
labeled
event and create a template comment of proposal.
Authenticating with the GITHUB_TOKEN - GitHub Docs
When you use the repository's
GITHUB_TOKEN
to perform tasks, events triggered by theGITHUB_TOKEN
, with the exception ofworkflow_dispatch
andrepository_dispatch
, 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'sGITHUB_TOKEN
, a new workflow will not run even when the repository contains a workflow configured to run whenpush
events occur.
You need to provide a personal access token (with public_repo
for a public repository, repo
for a private repository) to an auto label GitHub Actions or GitHub Bot like actions/labeler.
# .github/workflows/labeler.yml
name: "Pull Request Labeler"
on:
- pull_request_target
jobs:
triage:
runs-on: ubuntu-20.04
permissions: {}
timeout-minutes: 1
steps:
- uses: actions/labeler@v3
with:
repo-token: "${{ secrets.GH_PAT }}"
Scenario:
- Someone updates the README.md and opens a pull-request.
- actions/labeler adds the documentation label automatically.
- peaceiris/actions-label-commenter creates the template comment automatically.
Select Label | Labeled |
---|---|
Multiple issues will be closed.