All Projects → srvaroa → labeler

srvaroa / labeler

Licence: MIT license
GitHub Action to assign labels to PRs based on configurable conditions

Programming Languages

go
31211 projects - #10 most used programming language
Makefile
30231 projects
Dockerfile
14818 projects

Projects that are alternatives of or similar to labeler

scan-action
Anchore container analysis and scan provided as a GitHub Action
Stars: ✭ 140 (+197.87%)
Mutual labels:  actions, github-actions
danger-action
Execute danger action for GitHub Actions.
Stars: ✭ 24 (-48.94%)
Mutual labels:  actions, github-actions
deploy-cloudrun
This action deploys your container image to Cloud Run.
Stars: ✭ 238 (+406.38%)
Mutual labels:  actions, github-actions
verify-changed-files
Github action to verify file changes that occur during the workflow execution.
Stars: ✭ 62 (+31.91%)
Mutual labels:  actions, github-actions
branch-names
Github action to retrieve branch or tag names with support for all events.
Stars: ✭ 99 (+110.64%)
Mutual labels:  actions, github-actions
gh-action-get-changed-files
GitHub Action that saves changed files as JSON for use by other actions.
Stars: ✭ 82 (+74.47%)
Mutual labels:  actions, github-actions
action-netlify-deploy
🙌 Netlify deployments via GitHub actions
Stars: ✭ 32 (-31.91%)
Mutual labels:  actions, github-actions
actions
A set of GitHub actions for Infracost. See cloud cost estimates for Terraform in pull requests. 💰📉 Love your cloud bill!
Stars: ✭ 147 (+212.77%)
Mutual labels:  actions, github-actions
mc-publish
GitHub Action that helps you publish your Minecraft mods
Stars: ✭ 76 (+61.7%)
Mutual labels:  actions, github-actions
Real Time Social Media Mining
DevOps pipeline for Real Time Social/Web Mining
Stars: ✭ 22 (-53.19%)
Mutual labels:  actions, github-actions
k8s-create-secret
GitHub Action to create Kubernetes cluster secrets
Stars: ✭ 24 (-48.94%)
Mutual labels:  actions, github-actions
add-an-issue-reference-action
A GitHub Action for adding a related issue reference to a pull request.
Stars: ✭ 19 (-59.57%)
Mutual labels:  actions, github-actions
changed-files
Github action to retrieve all (added, copied, modified, deleted, renamed, type changed, unmerged, unknown) files and directories.
Stars: ✭ 733 (+1459.57%)
Mutual labels:  actions, github-actions
csharp-docs-generator
An action that generates html documentation for C# programs to use for GitHub pages.
Stars: ✭ 21 (-55.32%)
Mutual labels:  actions, github-actions
public-ip
Queries GitHub actions runner's public IP address
Stars: ✭ 64 (+36.17%)
Mutual labels:  actions, github-actions
dart-package-publisher
Action to Publish Dart / Flutter Package To https://pub.dev When you need to publish a package, just bump the version in pubspec.yaml
Stars: ✭ 45 (-4.26%)
Mutual labels:  actions, github-actions
chrome-addon
☁ GitHub action to upload addon to Chrome
Stars: ✭ 53 (+12.77%)
Mutual labels:  actions, github-actions
python-actions-alpha-archived
Please note that this was for the *alpha* version of GitHub Actions for Python.
Stars: ✭ 15 (-68.09%)
Mutual labels:  actions, github-actions
setup-jdk
(DEPRECATED) Set up your GitHub Actions workflow with a specific version of AdoptOpenJDK
Stars: ✭ 32 (-31.91%)
Mutual labels:  actions, github-actions
clojure-dependency-update-action
A simple GitHub Actions job to create Pull Requests for outdated dependencies in clojure projects
Stars: ✭ 37 (-21.28%)
Mutual labels:  actions, github-actions

Condition based Pull Request Labeler

Implements a GitHub Action that labels Pull Requests based on configurable conditions.

It is inspired by the example Pull Request Labeller, but intends to provide a richer set of options.

Installing

Add a file .github/workflows/main.yml to your repository with these contents:

name: Label PRs

on:
- pull_request

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: srvaroa/labeler@master
      env:
        GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

Then add a new file .github/labeler.yml with the configuration as described below in the Configuration section.

If you want to run the action on the base of the pull request, rather than on the merge commit, you should trigger the action on pull_request_target. Check the GitHub documentation for more details.

This action will avoid failing in all cases, so if you're experiencing unexpected behaviour it's worth looking at execution logs just in case. Typical errors are:

  • The configuration file is non existent, or has invalid yaml.
  • Running the action from a fork, as the GITHUB_TOKEN has not enough permissions to label the main repository (issue for solving this)

Configuration

Configuration can be stored at .github/labeler.yml as a plain list of label matchers, which consist of a label and a set of conditions for each. When all conditions for a label match, then the Action will set the given label. When any condition for a label does not match, then the Action will unset the given label.

Here is an example of a matcher for label "Example":

<label>: "Example"
<condition_name>: <condition_parameters>
<condition_name>: <condition_parameters>

For example, this .github/labeler.yml contains a single matcher with a single condition:

version: 1
labels:
- label: "WIP"
  title: "^WIP:.*"

A Pull Request with title "WIP: this is work in progress" would be labelled as WIP. If the Pull Request title changes to "This is done", then the WIP label would be removed.

Each label may combine multiple conditions. The action combines all conditions with an AND operation. That is, the label will be applied if all conditions are satisfied, removed otherwise.

For example, given this .github/labeler.yml:

version: 1
labels:
- label: "WIP"
  title: "^WIP:.*"
  mergeable: false

A Pull Request with title "WIP: this is work in progress" and not in a mergeable state would be labelled as WIP. If the Pull Request title changes to "This is done", or it becomes mergeable, then the WIP label would be removed.

If you wish to apply an OR, you may set multiple matchers for the same label. For example:

version: 1
labels:
- label: "WIP"
  title: "^WIP:.*"
- label: "WIP"
  mergeable: false

The WIP label will be set if the title matches ^WIP:.* OR the label is not in a mergeable state.

Append-only mode

The default behaviour of this action includes removing labels that have a rule configured that does not match anymore. For example, given this configuration:

version: 1
labels:
- label: "WIP"
  title: "^WIP:.*"

A PR with title 'WIP: my feature' will get the WIP label.

Now the title changes to My feature. Since the labeler configuration includes the WIP label, and its rule does not match anymore, the label will get removed.

In some cases you would prefer that the action adds labels, but never removes them regardless of the matching status. To achieve this you can enable the appendOnly flag.

version: 1
appendOnly: true
labels:
- label: "WIP"
  title: "^WIP:.*"

With this config, the behaviour changes:

  • A PR with title 'WIP: my feature' will get the WIP label.
  • When the title changes to My feature, even though the labeler has a rule for the WIP label that does not match, the label will be respected.

Conditions

Below are the conditions currently supported in label matchers.

Regex on title

This condition is satisfied when the PR title matches on the given regex.

title: "^WIP:.*"

Regex on branch

This condition is satisfied when the PR branch matches on the given regex.

branch: "^feature/.*"

Regex on base branch

This condition is satisfied when the PR base branch matches on the given regex.

base-branch: "master"

Regex on PR body

This condition is satisfied when the body (description) matches on the given regex.

body: "^patch.*"

Regex on PR files

This condition is satisfied when any of the PR files matches on the given regexs.

files: 
- "cmd/.*_tests.go"

Mergeable status

This condition is satisfied when the PR is in a mergeable state.

mergeable: true

Match to PR Author

This condition is satisfied when the PR author matches any of the given usernames.

author: "serubin"

PR size

This condition is satisfied when the total number of changed lines in the PR is within given thresholds.

The number of changed lines is calculated as the sum of all additions + deletions in the PR.

For example, given this .github/labeler.yml:

- label: "S"
  size-below: 10
- label: "M"
  size-above: 9
  size-below: 100
- label: "L"
  size-above: 100

These would be the labels assigned to some PRs, based on their size as reported by the GitHub API.

PR additions deletions Resulting labels
First example 1 1 S
Second example 5 42 M
Third example 68 148 L
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].