Giter Club home page Giter Club logo

labeler's Introduction

labeler

FOSSA Status

A labeler for GitHub issues and pull requests.

A labeler for GitHub issues and pull requests.

Usage:
  labeler [flags]

Flags:
      --config-path string   A custom config path, relative to the repository root
      --data string          A JSON string of the 'event' type (issue event or pull request event)
  -h, --help                 help for labeler
      --id int               The integer id of the issue or pull request
  -o, --owner string         GitHub Owner/Org name [GITHUB_ACTOR]
  -r, --repo string          GitHub Repo name [GITHUB_REPO]
  -t, --type string          The target event type to label (issues or pull_request) [GITHUB_EVENT_NAME]
  -v, --version              version for labeler

Example usage:

export GITHUB_TOKEN=yourtoken
./labeler -o jimschubert -r labeler -type pull_request -id 1

This will evaluate the configuration file for the repository and apply any relevant labels to PR #1.

Configuration

The configuration file must be located in the target repository at .github/labeler.yml by default, and the contents must follow either the simple schema or the full schema.

The configuration file location can be modified by passing a different path to --config-path. This path must be relative to the repository root. All of the following would be valid possible customizations (assuming you've created a configuration file at that location):

  • .github/labeler-custom.yml
  • tools/labeler.yml
  • .labeler.yml

Feel free to use one of the following schema examples to get started.

Simple Schema

# labeler "simple" schema
# Comment is applied to both issues and pull requests.
# If you need a more robust solution, consider the "full" schema.
comment: |
  ๐Ÿ‘ Thanks for this!
  ๐Ÿท I have applied any labels matching special text in your issue.

  Please review the labels and make any necessary changes.

# Labels is an object where:
# - keys are labels
# - values are array of string patterns to match against title + body in issues/prs
labels:
  'bug':
    - '\bbug[s]?\b'
  'help wanted':
    - '\bhelp( wanted)?\b'
  'duplicate':
    - '\bduplicate\b'
    - '\bdupe\b'
  'enhancement':
    - '\benhancement\b'
  'question':
    - '\bquestion\b'

Full Schema

# labeler "full" schema

# enable labeler on issues, prs, or both.
enable:
  issues: true
  prs: true
# comments object allows you to specify a different message for issues and prs

comments:
  issues: |
    Thanks for opening this issue!
    I have applied any labels matching special text in your title and description.

    Please review the labels and make any necessary changes.
  prs: |
    Thanks for the contribution!
    I have applied any labels matching special text in your title and description.

    Please review the labels and make any necessary changes.

# Labels is an object where:
# - keys are labels
# - values are objects of { include: [ pattern ], exclude: [ pattern ] }
#    - pattern must be a valid regex, and is applied globally to
#      title + description of issues and/or prs (see enabled config above)
#    - 'include' patterns will associate a label if any of these patterns match
#    - 'exclude' patterns will ignore this label if any of these patterns match
labels:
  'bug':
    include:
      - '\bbug[s]?\b'
    exclude: []
  'help wanted':
    include:
      - '\bhelp( me)?\b'
    exclude:
      - '\b\[test(ing)?\]\b'
  'enhancement':
    include:
      - '\bfeat\b'
    exclude: []

Build

Build a local distribution for evaluation using goreleaser.

goreleaser release --skip-publish --snapshot --rm-dist

This will create an executable application for your os/architecture under dist:

dist
โ”œโ”€โ”€ labeler_darwin_amd64_v1
โ”‚ย ย  โ””โ”€โ”€ labeler
โ”œโ”€โ”€ labeler_darwin_arm64
โ”‚ย ย  โ””โ”€โ”€ labeler
โ”œโ”€โ”€ labeler_linux_386
โ”‚ย ย  โ””โ”€โ”€ labeler
โ”œโ”€โ”€ labeler_linux_amd64_v1
โ”‚ย ย  โ””โ”€โ”€ labeler
โ”œโ”€โ”€ labeler_linux_arm64
โ”‚ย ย  โ””โ”€โ”€ labeler
โ”œโ”€โ”€ labeler_linux_arm_6
โ”‚ย ย  โ””โ”€โ”€ labeler
โ”œโ”€โ”€ labeler_windows_amd64_v1
โ”‚ย ย  โ””โ”€โ”€ labeler.exe
โ”œโ”€โ”€ labeler_windows_arm64
โ”‚ย ย  โ””โ”€โ”€ labeler.exe
โ”œโ”€โ”€ labeler_windows_arm_6
โ”‚ย ย  โ””โ”€โ”€ labeler.exe

License

The labeler project is licensed under Apache 2.0

labeler is a rewrite of an earlier GitHub App I wrote (see auto-labeler). I've rewritten that app to replace the license while making the tool reusable across CI tools and operating systems.

FOSSA Status

labeler's People

Contributors

fossabot avatar jimschubert avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

fossabot

labeler's Issues

[bug] Hardcoded default branch "master" causes Workflow failure if Default Branch is not called master

Describe the bug

Hey there! First of all, I really love this project! However, I've found a bug while setting it up as I ran this workflow in one of my projects.

I know I used your project labeler-action, but I was able to locate the root of the problem is this repository. This is the exception thrown: time="2020-08-03T08:22:06Z" level=fatal msg="Failed to execute GET https://api.github.com/repos/niklas2810/maven-template/contents/.github?ref=master: 404 No commit found for the ref master []"

In labeler.go, you simply request the labeler.yml file for the branch master. Due to github/renaming, I now call my default branch main. Hardcoding master should not be considered good practice, as GitHub plans to make main the default name for the primary branch. Source:

r, err := l.client.Repositories.DownloadContents(ctx, *l.Owner, *l.Repo, ".github/labeler.yml", &github.RepositoryContentGetOptions{Ref: "master"})

To Reproduce
Steps to reproduce the behavior:

  1. Create a new GitHub repo with a default branch called main.
  2. Run the labeler action (or the labeler via terminal).

Expected behavior/Fix
The labeler should request the labeler.yml file from the default branch, which is not necessarily called master. As far as I can see, you can simply leave out the ref parameter to retrieve the file. This link (=yours without ref) works fine for me: https://api.github.com/repos/niklas2810/maven-template/contents/.github

I have no experience in Go, which is why I don't want to open a pull request myself.

Screenshots
Error message and link to workflow linked above.

Thank you so much for this project! I hope that my bug report will help you with fixing this issue ๐Ÿ˜„

Is there a way to label based on branches?

What is your question?
Is there a way to label based on target branches?

Where did you look before asking here?
I didn't see any examples in showing how to do this in the configuration yml files.

Additional context
The use case I have is a repo with a main branch for doing development things and a prod branch for controlling the production deployments. I'd like to be able to label any PRs that target the prod branch as deployment for example.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.