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.
- 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.
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.
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.
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. |
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'
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/**'
- The Action triggers based on GitHub events (
issues
orpull_request
). - Matches keywords (for issues) or file patterns (for pull requests) against the configuration file.
- Applies labels to issues or pull requests that match the criteria.
- Optionally creates missing labels in the repository.
This repository is licensed under the MIT License.
© Vedansh 2020 - Present
Licensed under MIT
Thanks for visiting :)