{"id":23799364,"url":"https://github.com/srvaroa/labeler","last_synced_at":"2025-04-12T18:53:58.619Z","repository":{"id":43118903,"uuid":"203668074","full_name":"srvaroa/labeler","owner":"srvaroa","description":"Label manager for PRs and Issues based on configurable conditions","archived":false,"fork":false,"pushed_at":"2024-10-13T10:49:21.000Z","size":226,"stargazers_count":83,"open_issues_count":7,"forks_count":41,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-25T05:27:06.312Z","etag":null,"topics":["actions","automation","codereview","github","github-actions","go","golang","issues","labels","labels-generator","project-management","pull-requests"],"latest_commit_sha":null,"homepage":"https://github.com/srvaroa/labeler","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/srvaroa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"srvaroa","custom":["https://buy.stripe.com/00g8yS1E6eml2t26oo"]}},"created_at":"2019-08-21T21:37:55.000Z","updated_at":"2024-10-13T10:49:24.000Z","dependencies_parsed_at":"2024-01-16T03:16:15.576Z","dependency_job_id":"71c79b36-aafe-4a5b-ac2b-9b07903880a4","html_url":"https://github.com/srvaroa/labeler","commit_stats":{"total_commits":170,"total_committers":18,"mean_commits":9.444444444444445,"dds":0.3176470588235294,"last_synced_commit":"e782b66d7a833341b1e35f9f23a2102aa6c35035"},"previous_names":[],"tags_count":35,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/srvaroa%2Flabeler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/srvaroa%2Flabeler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/srvaroa%2Flabeler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/srvaroa%2Flabeler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/srvaroa","download_url":"https://codeload.github.com/srvaroa/labeler/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248618263,"owners_count":21134200,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["actions","automation","codereview","github","github-actions","go","golang","issues","labels","labels-generator","project-management","pull-requests"],"created_at":"2025-01-01T21:15:26.464Z","updated_at":"2025-04-12T18:53:58.598Z","avatar_url":"https://github.com/srvaroa.png","language":"Go","readme":"# Label manager for PRs and issues based on configurable conditions\n\n[![labeler release (latest SemVer)](https://img.shields.io/github/v/release/srvaroa/labeler?sort=semver)](https://github.com/srvaroa/labeler/releases)  [![sponsor the project!](https://img.shields.io/static/v1?label=Sponsor\u0026message=%E2%9D%A4\u0026logo=GitHub\u0026color=%23fe8e86)](https://github.com/sponsors/srvaroa)\n\nImplements an all-in-one [GitHub\nAction](https://help.github.com/en/categories/automating-your-workflow-with-github-actions)\nthat can manage multiple labels for both Pull Requests and Issues using\nconfigurable matching rules. Available conditions:\n\n* [Age](#age): label based on the age of a PR or Issue\n* [Author can merge](#author-can-merge): label based on whether the author can merge the PR\n* [Author is member of team](#author-in-team): label based on whether the author is an active member of the given team\n* [Authors](#authors): label based on the PR/Issue authors\n* [Base branch](#base-branch): label based on the PR's base branch name\n* [Body](#body): label based on the PR/Issue body\n* [Branch](#branch): label based on the PR's branch name\n* [Draft](#draft): label based on whether the PR is a draft\n* [Files](#files): label based on the files modified in the PR\n* [Last modified](#last-modified): label based on the last modification to a PR or Issue\n* [Mergeable](#mergeable): label based on whether the PR is mergeable\n* [Size](#size): label based on the PR size, allowing file exclusions\n* [Title](#title): label based on the PR/Issue title\n* [Type](#type): label based on record type (PR or Issue)\n\n## Sponsors\n\nPlease consider supporting the project if your organization finds it useful,\nyou can do this through [GitHub Sponsors](https://github.com/sponsors/srvaroa).\nSponsorships also help speed up bug fixes or new features.\n\nThanks to [Launchgood](https://github.com/launchgood) and others that\npreferred to remain private for supporting this project!\n\n## Installing\n\nThe action is configured by adding a file `.github/labeler.yml` (which\nyou can override). The file contains matching rules expanded in the\n`Configuration` section below.\n\nThe action will strive to maintain backwards compatibility with older\nconfiguration versions. It is nevertheless encouraged to update your\nconfiguration files to benefit from newer features. Please follow our\n[releases](https://github.com/srvaroa/labeler/releases) page to stay up\nto date.\n\n### GitHub Enterprise support\n\nAdd `GITHUB_API_HOST` to your env variables, it should be in the form\n`http(s)://[hostname]/`\n\nPlease consider [sponsoring the project](https://github.com/sponsors/srvaroa) if you're using Labeler in your organization!\n\n### How to trigger action\n\nTo trigger the action on events, add a file `.github/workflows/main.yml`\nto your repository:\n\n```yaml\nname: Label PRs\n\non:\n- pull_request\n- issues\n\njobs:\n  build:\n\n    runs-on: ubuntu-latest\n\n    steps:\n    - uses: srvaroa/labeler@master\n      env:\n        GITHUB_TOKEN: \"${{ secrets.GITHUB_TOKEN }}\"\n```\n\nUsing `@master` will run the latest available release. Feel free to pin\nthis to a specific version from the [releases\npage](https://github.com/srvaroa/labeler/releases). We also maintain a\nfloating tag on the major `v1`. This gets updated whenever a new\nminor/patch v1.x.y version is released.\n\nUse the [`on`\nclause](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows)\nto control when to run it.\n\n* To trigger on PR events, [use\n  `pull_request`](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request).\n  to trigger on PR events and run on the merge commit of the PR. Use\n  [`pull_request_target`](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target)\n  instead if you prefer to run on the base.\n* To trigger on issue events, add [`issues`](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#issues).\n\nYou may combine multiple event triggers.\n\n\u003ca name=\"schedule\" /\u003eA final option is to trigger the action periodically using the\n[`schedule`](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule)\ntrigger. For backwards compatibility reasons this will examine all\nactive pull requests and update their labels. If you wish to examine\nissues as well, you'll need to explicitly add the `issues` flag in your\nconfig file:\n\n```yaml\nversion: 1\nissues: True\nlabels:\n- label: \"WIP\"\n  title: \"^WIP:.*\"\n```\n\n### Advanced action settings\n\nPlease refer to the [action.yml](action.yml) file in the repository\nfor the available inputs to the action. Below is an example using all of\nthem:\n\n```yaml\nname: Label PRs\n\non:\n- pull_request\n- issues\n\njobs:\n  build:\n\n    runs-on: ubuntu-latest\n\n\n    steps:\n\n    - name: Checkout your code\n      uses: actions/checkout@v3\n\n    - uses: srvaroa/labeler@master\n      with:\n        config_path: .github/labeler.yml\n        use_local_config: false\n        fail_on_error: false\n      env:\n        GITHUB_TOKEN: \"${{ secrets.GITHUB_TOKEN }}\"\n```\n\nUse `config_path` to provide an alternative path for the configuration\nfile for the action. The default is `.github/labeler.yml`.\n\nUse `use_local_config` to chose where to read the config file from. By\ndefault, the action will read the file from the default branch of your\nrepository. If you set `use_local_config` to `true`, then the action\nwill read the config file from the local checkout. Note that you may\nneed to checkout your branch before the action runs!\n\nUse `fail_on_error` to decide whether an error in the action execution\nshould trigger a failure of the workflow. By default it's disabled to\nprevent the action from disrupting CI pipelines.\n\n## Troubleshooting\n\nTo avoid blocking CI pipelines, the action will never return an error\ncode and just log information about the problem. Typical errors are\nrelated to non-existing configuration file or invalid yaml.\n\n## Configuring matching rules\n\nConfiguration can be stored at `.github/labeler.yml` as a plain list of\nlabel matchers, which consist of a label and a set of conditions for\neach.  When *all* conditions for a label match, then the Action will set\nthe given label.  When *any* condition for a label does not match, then\nthe Action will unset the given label.\n\nAll matchers follow this configuration pattern:\n\n```yaml\n\u003clabel\u003e: \"MyLabel\"\n\u003ccondition_name\u003e: \u003ccondition_parameters\u003e\n\u003ccondition_name\u003e: \u003ccondition_parameters\u003e\n```\n\nFor example, this `.github/labeler.yml` contains a single matcher with\na single condition:\n\n```yaml\nversion: 1\nlabels:\n- label: \"WIP\"\n  title: \"^WIP:.*\"\n```\n\nA PR or issue with title \"WIP: this is work in progress\" would be\nlabelled as `WIP`.  If the title changes to \"This is done\", then the\n`WIP` label would be removed.\n\nEach label may combine multiple conditions.  The action combines all\nconditions with an AND operation.  That is, the label will be applied if\n*all* conditions are satisfied, removed otherwise.\n\nFor example, given this `.github/labeler.yml`:\n\n```yaml\nversion: 1\nlabels:\n- label: \"WIP\"\n  title: \"^WIP:.*\"\n  mergeable: false\n```\n\nA pull request with title \"WIP: this is work in progress\" *and* not in a\nmergeable state would be labelled as `WIP`.  If the title changes to\n\"This is done\", or it becomes mergeable, then the `WIP` label would be\nremoved.\n\nIf you wish to apply an OR, you may set multiple matchers for the same\nlabel. For example:\n\n```yaml\nversion: 1\nlabels:\n- label: \"WIP\"\n  title: \"^WIP:.*\"\n- label: \"WIP\"\n  mergeable: false\n```\n\nThe `WIP` label will be set if the title matches `^WIP:.*` OR the label\nis not in a mergeable state.\n\n### Negate rules\n\nAdding a `negate` property inside the label block will negate the\nresult of the evaluation of all conditions inside the label. For\nexample:\n\n```yaml\nversion: 1\nlabels:\n- label: \"unknown\"\n  negate: True\n  branch: \"(master|hotfix)\"\n```\n\nIn this case, label `unknown` will be set if the branch does NOT match\n`master` or `hotfix`.\n\nThe same behaviour occurs with multiple conditions:\n\n```yaml\nversion: 1\nlabels:\n- label: \"unknown\"\n  negate: True\n  branch: \"master\"\n  title: \"(feat).*\"\n```\n\nOnly PRs that do NOT match one of the two conditions will get the\n`unknown` label.\n\n## Append-only mode\n\nThe default behaviour of this action includes *removing* labels that\nhave a rule configured that does not match anymore. For example, given\nthis configuration:\n\n```yaml\nversion: 1\nlabels:\n- label: \"WIP\"\n  title: \"^WIP:.*\"\n```\n\nA PR or issue with title 'WIP: my feature' will get the `WIP` label.\n\nNow the title changes to `My feature` the label will get remove. This is\nbecause the labeler configuration includes the `WIP` label, and its rule\ndoes not match anymore.\n\nIn some cases you would prefer that the action adds labels, but never\nremoves them regardless of the matching status. To achieve this you can\nenable the `appendOnly` flag.\n\n```yaml\nversion: 1\nappendOnly: true\nlabels:\n- label: \"WIP\"\n  title: \"^WIP:.*\"\n```\n\nWith this config, the behaviour changes:\n\n- A PR with title 'WIP: my feature' will get the `WIP` label.\n- When the title changes to `My feature`, even though the labeler has a\n  rule for the `WIP` label that does not match, the label will be\n  respected.\n\n## Conditions\n\nBelow are the conditions currently supported in label matchers, in\nalphabetical order. Some important considerations:\n\n* Conditions evaluate only when they are explicitly added in\n  configuration. There are no defaults.\n* Some conditions are only applicable to pull requests.\n* All conditions based on regex rely on [Go's `regexp`\n  package](https://pkg.go.dev/regexp), which accepts the syntax accepted\n  by RE2 and described at [golang.org](https://golang.org/s/re2syntax).\n  You can use tools like [regex101.com](https://regex101.com/?flavor=golang)\n  to verify your conditions.\n\n### Age (PRs and Issues) \u003ca name=\"age\" /\u003e\n\nThis condition evaluates the creation date of the PR or Issue.\n\nIf you're looking to evaluate on the modification date of the issue or PR,\ncheck on \u003ca href=\"#last-modified\" \u003e\u003c/a\u003e\n\nThis condition is best used when with a \u003ca href=\"#schedule\"\u003eschedule trigger\u003c/a\u003e.\n\nExamples:\n\n```yaml\nage-range:\n  at-most: 1d\n```\n\nWill label PRs or issues that were created at most one day ago.\n\n```yaml\nage-range:\n  at-least: 1w\n```\n\nWill label PRs or issues that were created at least one week ago.\n\nThe syntax for values is based on a number, followed by a suffix:\n\n* s: seconds\n* m: minutes\n* h: hours\n* d: days\n* w: weeks\n* y: years\n\nFor example, `2d` means 2 days, `4w` means 4 weeks, and so on.\n\n### Author can merge (PRs) \u003ca name=\"author-can-merge\" /\u003e\n\nThis condition is satisfied when the author of the PR can merge it.\nThis is implemented by checking if the author is an owner of the repo.\n\n```yaml\nauthor-can-merge: True\n```\n\n\n### Author is member (PRs and Issues) \u003ca name=\"author-in-team\" /\u003e\n\nThis condition is satisfied when the author of the PR is an active\nmember of the given team (identified by its url slug).\n\n```yaml\nauthor-in-team: core-team\n```\n\n### Authors (PRs and Issues)  \u003ca name=\"authors\" /\u003e\n\nThis condition is satisfied when the author of the PR or Issue matches\nany of the given usernames.\n\n```yaml\nauthors: [\"serubin\"]\n```\n\n### Base branch (PRs only) \u003ca name=\"base-branch\" /\u003e\n\nThis condition is satisfied when the PR base branch matches on the given\nregex.\n\n```yaml\nbase-branch: \"master\"\n```\n\n### Body (PRs and Issues) \u003ca name=\"body\" /\u003e\n\nThis condition is satisfied when the body (description) matches on the\ngiven regex.\n\n``` yaml\nbody: \"^patch.*\"\n```\n\n### Branch (PRs only) \u003ca name=\"branch\" /\u003e\n\nThis condition is satisfied when the PR branch matches on the given\nregex.\n\n```yaml\nbranch: \"^feature/.*\"\n```\n\n### Draft status (PRs only) \u003ca name=\"draft\" /\u003e\n\nThis condition is satisfied when the PR [draft\nstate](https://developer.github.com/v3/pulls/#response-1) matches that of the\nPR.\n\n```yaml\ndraft: True\n```\n\nMatches if the PR is a draft.\n\n```yaml\ndraft: False\n```\n\nMatches if the PR is not a draft.\n\n### Files affected (PRs only) \u003ca name=\"files\" /\u003e\n\nThis condition is satisfied when any of the PR files matches on the\ngiven regexs.\n\n```yaml\nfiles:\n- \"cmd\\\\/.*_tests.go\"\n- \".*\\\\/subfolder\\\\/.*\\\\.md\"\n```\n\n\u003e **NOTICE** the double backslash (`\\\\`) in the example above. This GitHub\nAction is coded in Go (Golang), which means you need to pay special attention to\nregular expressions (Regex). Special characters need to be escaped with double\nbackslashes. This is because the backslash in Go strings is an escape character\nand therefore must be escaped itself to appear as a literal in the regex.\n\n### Last Modified (PRs and Issues) \u003ca name=\"last-modified\" /\u003e\n\nThis condition evaluates the modification date of the PR or Issue.\n\nIf you're looking to evaluate on the creation date of the issue or PR,\ncheck on \u003ca href=\"#age\" \u003e\u003c/a\u003e\n\nThis condition is best used when with a \u003ca href=\"#schedule\"\u003eschedule trigger\u003c/a\u003e.\n\nExamples:\n\n```yaml\nlast-modified:\n  at-most: 1d\n```\nWill label PRs or issues that were last modified at most one day ago\n\n```yaml\nlast-modified:\n  at-least: 1d\n```\n\nWill label PRs or issues that were last modified at least one day ago\n\nThe syntax for values is based on a number, followed by a suffix:\n\n* s: seconds\n* m: minutes\n* h: hours\n* d: days\n* w: weeks\n* y: years\n\nFor example, `2d` means 2 days, `4w` means 4 weeks, and so on.\n\n### Mergeable status (PRs only) \u003ca name=\"mergeable\" /\u003e\n\nThis condition is satisfied when the [mergeable\nstate](https://developer.github.com/v3/pulls/#response-1) matches that\nof the PR.\n\n```yaml\nmergeable: True\n```\n\nWill match if the label is mergeable.\n\n```yaml\nmergeable: False\n```\n\nWill match if the label is not mergeable.\n\n### Size (PRs only) \u003ca name=\"size\" /\u003e\n\nThis condition is satisfied when the total number of changed lines in\nthe PR is within given thresholds.\n\nThe number of changed lines is calculated as the sum of all `additions +\ndeletions` in the PR.\n\nFor example, given this `.github/labeler.yml`:\n\n```yaml\n- label: \"S\"\n  size:\n      below: 10\n- label: \"M\"\n  size:\n      above: 9\n      below: 100\n- label: \"L\"\n  size:\n      above: 100\n```\n\nThese would be the labels assigned to some PRs, based on their size as\nreported by the [GitHub API](https://developer.github.com/v3/pulls).\n\n|PR|additions|deletions|Resulting labels|\n|---|---|---|---|\n|First example|1|1|S|\n|Second example|5|42|M|\n|Third example|68|148|L|\n\nYou can exclude some files so that their changes are not taken into\naccount for the overall count. This can be useful for `yarn.lock`,\n`go.sum` and such. Use `exclude-files`, which supports both an explicit\nfile or a Regex expression:\n\n```yaml\n- label: \"L\"\n    size:\n        exclude-files: [\"yarn.lock\", \"\\\\/root\\\\/.+\\\\/test.md\"]\n        above: 100\n```\n\nThis condition will apply the `L` label if the diff is above 100 lines,\nbut NOT taking into account changes in `yarn.lock`, or any `test.md`\nfile that is in a subdirectory of `root`.\n\n**NOTICE** the double backslash (`\\\\`) in the example above. This GitHub\nAction is coded in Go (Golang), which means you need to pay special attention to\nregular expressions (Regex). Special characters need to be escaped with double\nbackslashes. This is because the backslash in Go strings is an escape character\nand therefore must be escaped itself to appear as a literal in the regex.\n\n**NOTICE** the old format for specifying size properties (`size-above`\nand `size-below`) has been deprecated. The action will continue\nsupporting old configs for now, but users are encouraged to migrate to\nthe new configuration schema.\n\n### Title \u003ca name=\"title\" /\u003e\n\nThis condition is satisfied when the title matches on the given regex.\n\n```yaml\ntitle: \"^WIP:.*\"\n```\n\n### Type \u003ca name=\"type\" /\u003e\n\nBy setting the type attribute in your label configuration, you can specify whether a rule applies exclusively to Pull\nRequests (PRs) or Issues. This allows for more precise label management based on the type of GitHub record. The\ntype condition accepts one of two values:\n\n- `pull_request`\n- `issue`\n\nThis functionality increases the adaptability of this GitHub Action, allowing users to create more tailored labeling\nstrategies that differentiate between PRs and Issues or apply universally to both.\n\n#### Pull-Request Only:\n\n```yaml\n- label: \"needs review\"\n  type: \"pull_request\"\n  name: \".*bug.*\"\n```\nThis rule applies the label \"needs review\" to Pull Requests with \"bug\" in the title.\n\n#### Issue Only:\n\n```yaml\n- label: \"needs triage\"\n  type: \"issue\"\n  name: \".*bug.*\"\n```\n\nThis rule applies the label \"needs triage\" to Issues with \"bug\" in the title.\n","funding_links":["https://github.com/sponsors/srvaroa","https://buy.stripe.com/00g8yS1E6eml2t26oo"],"categories":["Go"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsrvaroa%2Flabeler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsrvaroa%2Flabeler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsrvaroa%2Flabeler/lists"}