Home

Awesome

title-to-labels-action

Cleans up the titles of issues and PRs from common opening keywords

GitHub offers issue templates with pre-defined labels, but that doesn't stop users from cluttering the titles with the same piece of information already offered by labels.

This action:

You can either run it without inputs to use its defaults or specify your own keywords/labels combination.

Title examples:

<table> <tr> <th>User title <th>➡️ Updated title <th>➡️ Added labels <tr> <td>Bug - some error happened <td>Some error happened <td><code>bug</code> <code>triage</code> <tr> <td>[Feature request] prepare coffee <td>Prepare coffee <td><code>enhancement</code> <tr> <td>Suggestion: add more tags <td>Add more tags <td><em>none, title-change only</em> </table>

Note: keywords in titles are only recognized if followed by one of these characters: :-)]

Usage

Note: If no inputs are supplied, the action will use the defaults.

name: Labeler

on:
  pull_request_target:
    types: [opened, edited]
  issues:
    types: [opened, edited]

jobs:
  Label:
    runs-on: ubuntu-latest
    permissions:
      pull-requests: write
    steps:
      - uses: fregante/title-to-labels-action@v1
        with:
          token: ${{ secrets.GITHUB_TOKEN }}

You can automatically install the above with ghat:

npx ghat fregante/title-to-labels-action/workflow

Inputs

Note: If no inputs are supplied, the action will use the defaults.

Either use one keyword per line or comma-separed values. Note: Do not use lists starting with -, Actions doesn't support them.

Examples:

name: Labeler

on:
  pull_request_target:
    types: [opened, edited]
  issues:
    types: [opened, edited]

jobs:
  Label:
    runs-on: ubuntu-latest
    permissions:
      pull-requests: write
    steps:
      - uses: fregante/title-to-labels-action@v1
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          keywords: idea
          # If you don't specify `labels`, the action will just clean up the titles from your keywords.

      # The action can be used as many times as needed in a single job
      - uses: fregante/title-to-labels-action@v1
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          keywords: bug, bug report
          labels: bug

      - uses: fregante/title-to-labels-action@v1
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          keywords: |
            feature request
            suggestions
            enhancement
          labels: |
            enhancement

Outputs

None.

Related