This GitHub Action automatically prefixes the title of a pull request with an emoji based on predefined rules in a YAML configuration file located in the .github
folder.
It will default to .github/emoji-labels.yml
if not other path is specified.
name: PR Title Emoji
on: pull_request
jobs:
stats:
runs-on: ubuntu-latest
steps:
- name: Prefix Emoji to PR Title
uses: lisilinhart/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
# config_path: '.github/my-labels.yml' (optional)
To use this action, you need to create a configuration file in your repository's .github
folder
named emoji-labels.yml
. This configuration file defines rules that map emojis to specific regular
expressions for matching pull request titles. The action will check if the title of a pull request
matches any of the defined regular expressions and prepend the corresponding emoji if a match is found.
pull_requests
permission to be able to read and update pull request
titles. Go to https://github.com/OWNER/REPO/settings/actions
and under Workflow permissions
enable Read and write permissions.
The configuration file should be structured as follows:
labels:
- emoji: "🔨"
title: ".*build(:|\\().*"
- emoji: "🏗️"
title: ".*chore:.*"
- emoji: "🚑"
title: ".*hotfix.*"
# Add more rules as needed
The title
property is a regular expression that will be matched against the title of a pull request.
new RegExp(labels.title)
If a match exists and no other emoji is already present in the title, the emoji will be prepended to the title.