Skip to content

offensive-vk/auto-label

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

Auto-Label

The Auto-Label GitHub Action simplifies the process of adding labels to issues and pull requests in your repository. Powered by the GitHub Octokit API, this Action can match specific keywords or file patterns to apply labels automatically.

For a complete example, check the working workflow.


Features

  • Automatic Labeling: Apply labels to issues and pull requests based on custom rules.
  • Keyword Matching: Match specific keywords in issues to apply relevant labels.
  • File Pattern Matching: Automatically label pull requests based on modified file patterns.
  • Optional Label Creation: Create missing labels automatically.

Usage Examples

Apply Labels on Issues

steps:
  - name: Apply Labels on Issues
    if: github.event_name == 'issues'
    uses: offensive-vk/auto-label@v7
    with:
      create-labels: true # Optional, defaults to true
      github-token: ${{ secrets.GITHUB_TOKEN }} # Optional, defaults to ${{ secrets.GITHUB_TOKEN }}
      issue-config: .github/issues.yml # Required, path to the issue configuration file.

Apply Labels on Pull Requests

steps:
  - name: Apply Labels on Pull Requests
    if: github.event_name == 'pull_request'
    uses: offensive-vk/auto-label@v7
    with:
      create-labels: true # Optional, defaults to true
      github-token: ${{ secrets.GITHUB_TOKEN }} # Optional, defaults to ${{ secrets.GITHUB_TOKEN }}
      pr-config: .github/pr.yml # Required, path to the pull request configuration file.

Input Configuration

Configure inputs through the with: section of the Action. Below is the list of available options:

Input Default Value Description
github-token ${{ secrets.GITHUB_TOKEN }} The GitHub token for authenticating requests. You can use ${{ secrets.GITHUB_TOKEN }} or a personal access token (PAT) stored in your secrets.
issue-config .github/issues.yml Path to the YAML configuration file for labeling issues.
pr-config .github/pr.yml Path to the YAML configuration file for labeling pull requests.
create-labels true Whether to create missing labels in the repository.
debug false Whether to enable debug mode or not.

Configuration Files

Issue Configuration

Define rules to apply labels on issues based on keywords. Below is an example:

# .github/issues.yml
actual_label:
  - 'Match1'
  - 'Match2'
  - '...'

bug:
  - 'bug'
  - 'issue'
  - 'fix'

feature:
  - 'feature'
  - 'enhancement'

Pull Request Configuration

Define rules to apply labels on pull requests based on file patterns. Below is an example:

# .github/pr.yml
area/release:
  - 'release/**/*'
  - 'release_assets/**/*'
  - '**/*.assets'

area/build:
  - 'build/**/*'
  - 'resources/**'

How It Works

  1. The Action triggers based on GitHub events (issues or pull_request).
  2. Matches keywords (for issues) or file patterns (for pull requests) against the configuration file.
  3. Applies labels to issues or pull requests that match the criteria.
  4. Optionally creates missing labels in the repository.

License

This repository is licensed under the MIT License.


© Vedansh 2020 - Present
Licensed under MIT
hamster
Thanks for visiting :)