Git Product home page Git Product logo

decathlon / pull-request-labeler-action Goto Github PK

View Code? Open in Web Editor NEW
94.0 3.0 16.0 441 KB

:zap: Github action to label your pull requests auto-magically :sparkles:(using committed files)

Home Page: https://github.com/marketplace/actions/pr-label-by-files

License: Apache License 2.0

Dockerfile 7.59% JavaScript 3.53% TypeScript 88.88%
github-actions projects project-management typescript labels

pull-request-labeler-action's Introduction

THIS ACTION IS DEPRECATED AND ARCHIVED.

You should not use it anymore, A better alternative is https://github.com/actions/labeler

DEPRECATED, do not use anymore

Readme kept as archive


Result illustration


This repository provides a GitHub action to automatically label a pull request based on committed files.

Table of Contents

Common usage

When pushing, the action will be triggered and will look for committed files over your branch. It applies configured labels whenever it find a file whose name matches the associated regular expression.

Expected result after processing Action log messages

Breaking change

Starting from August 2019, GitHub switch Actions syntax from HCL to YAML. The previous syntax will no longer be supported by GitHub on September 30, 2019.

As a consequence, please use v2.0.0+ release and note that all v1.x.x are deprecated and will no longer work on September 30, 2019.

Startup

Configuration

Create a file into your root project directory: .github/label-pr.yml:

- regExp: ".*\\.ts+$"
  labels: ["typescript"]
- regExp: ".*\\.sql+$"
  labels: ["database", "critical"]
- regExp: ".*\\.md+$"
  labels: ["documentation"]
- regExp: "^(pom\\.xml|package\\.json|build\\.gradle)$"
  labels: ["dependencies"]
- regExp: ".*\\.(zip|jar|war|ear)+$"
  labels: ["artifact", "invalid"]

This is a sample to illustrate how you can customize your settings by configuring your own regex and labels

The configuration is made of a list of Filter which are composed of:

  • regExp: a regular expression which will be tested over the filenames
  • labels: a list of labels to apply if the filenames match

If the labels do not exist yet in your repository configuration, they will be created anyway.

Use GitHub action

Settings for v1.0.0+ release (deprecated)

Create a file into your root project directory (if it does not exist yet): .github/main.workflow:

workflow "New workflow" {
  resolves = ["PR label by Files"]
  on = "pull_request"
}

action "PR label by Files" {
  uses = "decathlon/[email protected]"
  secrets = ["GITHUB_TOKEN"]
}

Settings for v2.0.0+ release

Create a file into your root project directory: .github/workflows/labeler.yml:

# Workflow to associate labels automatically
name: labeler
# Trigger the workflow on pull request events
on: [pull_request]
jobs:
  label:
    runs-on: ubuntu-18.04
    steps:
      # We need to checkout the repository to access the configured file (.github/label-pr.yml)
      - uses: actions/checkout@v2
      - name: Labeler
        uses: docker://decathlon/pull-request-labeler-action:2.0.0
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          # Here we can override the path for the action configuration. If none is provided, default one is `.github/label-pr.yml`
          CONFIG_PATH: ${{ secrets.GITHUB_WORKSPACE }}/.github/label-pr.yml

Please note that you can move the label-pr.yml to another location, if so, then do not forget to update the above CONFIG_PATH variable.

Contributing

  • The project is built using Typescript # 3.5.2
  • We use a tslint as a linter for defining code style which configuration may change
  • We use Jest as the testing framework

To start, you just need to clone the repository and open it in your favorite IDE. You may need to set it up so it uses the node configuration (package.json) and tslint configuration (tslint.json).

Commands

  • To run unit tests: npm run test:watch
  • To build: npm run build:main

pull-request-labeler-action's People

Contributors

fossabot avatar gep13 avatar gregoirew avatar hisasann avatar lusoalex avatar mmornati avatar rdelgatte avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

pull-request-labeler-action's Issues

Excluding path

Hi :)

This is a great tool that I want to use in an Open Source environment.
My only issue is that I cannot figure out how to exclude a path from getting a label... Is this possible?

Kind regards,

Some help appreciated

I want to use this action to automatically label PRs for translations in my project.

The only - and for me most difficult - question I have is, what pattern I would need to use in order to only apply the label when the PR is towards those translations.
The translations always go towards json files located under src/resources/lang, the src/resources folder however also contains other json files for configuration settings and similar, so this should be ignored.

I'm not a pro at regex so Idk what would be a good pattern to cover the above requirements/rules.

Enhancement - Update labels instead of removing all / adding new ones

Scenario:

  1. Opening a new Pull request with documentation and tests files
  • Before: No Labels
  • After: ["documentation", "tests"]
  1. Adding a new label (manually - which is not configured): ["documentation", "tests", "manual-label"]
  2. Pushing once more but removing the documentation files from the pull request changes, I should have: ["tests", "manual-label"]

So I should only remove ["documentation"] in this case

Error building Docker

Hi, i just tried to set up the PR label action, this is how i configured it, following the documentation at
https://github.com/marketplace/actions/pr-label-by-files

This is my configuration file
Schermata 2021-10-11 alle 11 30 20

The problem is that the github test fails, outputting this error about Docker installation
Schermata 2021-10-11 alle 11 29 16

Complete log at https://pipelines.actions.githubusercontent.com/LzYT1jTHIIqkUqIVejfHz5PKS0a4Ln9lIjkGoSIu7hcrSGsXII/_apis/pipelines/1/runs/548/signedlogcontent/2?urlExpires=2021-10-11T09%3A36%3A41.9614721Z&urlSigningMethod=HMACV1&urlSignature=cx4nhAfNIpp5IrzPFGIlcoOdKwDOkVK1p7UMLEAVzbc%3D

Am i missing something about the configuration?

action not running sometimes

The labelling action is configured for my workflow, and it is working perfectly fine for almost 2 and a half months, but it is causing trouble. The problem is here it is not triggering for some pull requests, and it get resolved automatically after sometime. There is no pattern as it is happening for random pull request's, i need to quickly act upon this as this was a required status check in my workflow.Please help me out in this case :)

Support automatic review requests

In the same way that labels are automatically attached, would it be possible to also automatically request reviewers as well based on file regex?

The use case is pretty similar as with labels, but it would be extra helpful to be able to tag the specific domain expert, like

*.sql -> request review from DBA
*.js -> request review from front-end guy

etc.

fatal HttpError: Resource not accessible by integration

Hi there!
I added labeler, but it crashes with a following error:

✖  fatal     HttpError: Resource not accessible by integration 
    at response.text.then.message (/app/node_modules/@octokit/request/dist-node/index.js:66:23)
    at process._tickCallback (internal/process/next_tick.js:68:7)

workflow run: https://github.com/OpenDiablo2/OpenDiablo2/pull/1120/checks?check_run_id=2435495674
workflow file: https://github.com/OpenDiablo2/OpenDiablo2/blob/eb470533c42e2595f409b0b98caf020b4d361d43/.github/workflows/labeler.yaml

I suppose, that this happens if someone without merge access opens the pull request.

use stable version

Hello,
In order to fix a bug on the wiki page creator action, I switch the version to the latest docker image.

uses: docker://decathlon/wiki-page-creator-action:latest

Once we have created a 2.0.0 of this docker image, we should fix the version.
Regards,
Alexandre.

HttpError: Resource not accessible by integration

Why is this failing? Can you exclude pebcak on my end?

ℹ  info      Open sourced by
...
ℹ  info      Running Action
ℹ  info       Configured filters:  [ { regExp: '.*\\.rs+$', labels: [ 'rustlang' ] },
  { regExp: '.*\\.py+$', labels: [ 'python' ] },
  { regExp: '.*\\.c+$', labels: [ 'c-lang' ] },
  { regExp: '.*\\.cpp+$', labels: [ 'CPP' ] },
  { regExp: '.*\\.sh+$', labels: [ 'shell' ] },
  { regExp: '.*\\.bash+$', labels: [ 'bash' ] },
  { regExp: '.*\\.br+$', labels: [ 'brainfuck' ] },
  { regExp: '^(.*\\Cargo.toml)$', labels: [ 'dependencies' ] } ]
ℹ  info      Checking files list for PR#37
ℹ  info      Listing files (page: 1 | per_page: 100)...
ℹ  info      Loaded 2 files
ℹ  info      Checking files... [ 'ping', 'src/bin/main.py' ]
ℹ  info      Labels to remove:  []
ℹ  info      Labels to add:  [ 'python' ]
✖  fatal     HttpError: Resource not accessible by integration 
    at response.text.then.message (/app/node_modules/@octokit/request/dist-node/index.js:66:23)
    at process._tickCallback (internal/process/next_tick.js:68:7)
##[error]Docker run failed with exit code 1

Affected run: https://github.com/RXT0112/Zernit/pull/37/checks?check_run_id=427509002

Action don't check if the label is already applied

  1. Create a PR who add a label automatically
  2. Re-push modifications on this PR

If the first push already add a label, Action remove it and add it again.

Behavior expected: Check if the Action already exist and remove it only if it is necessary.

Capture d’écran 2019-07-29 à 16 31 50

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.