Coder Social home page Coder Social logo

issue-label-manager-action's Introduction

Issue Label Manager Action

This GitHub Action allows you to declaratively state the labels to be defined in a repo.

In the repo you'd like to use this, define a JSON file in .github/labels.json. This file will contain an array of objects that have a name, color, and description as shown in the example below.

labels.json file

Then, set up a workflow that executes this action. When run, it will update the list of labels in the repo to match the JSON file. If you wish for this to remove any labels not in the JSON file, set the delete input to true as shown in the example below.

The result of using the labels.json file shown above is as follows:

Labels result

If a label doesn't need a description, leave out the description field of the entry in the json file and when deployed the label will not contain a description.

Usage

This action only needs the GITHUB_TOKEN secret as it interacts with the GitHub API to modify labels. The action can be used as such:

on: issues
name: Create Default Labels
jobs:
  labels:
    name: DefaultLabelsActions
    runs-on: ubuntu-latest
    steps:
      - uses: actions/[email protected]
      - uses: lannonbr/[email protected]
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          delete: true # will delete any labels that aren't in the .github/labels.json (this is set to false by default)

issue-label-manager-action's People

Contributors

lannonbr avatar oalders avatar rolfkleef 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  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

issue-label-manager-action's Issues

Update action version in README to prevent loss of labels

I just added a PR to update the Action version in the README #17

When copying the example code, the delete option says it defaults to false, but when either setting it explicitly to false or removing the setting (trusting the default) will result in version 2 deleting labels.

Warning: Unexpected input(s) 'delete', valid inputs are ['']
Run lannonbr/[email protected]
[Action] Deleting Label: test

Label descriptions are not affected

I was trying this action in my repo, the label descriptions were neither created nor updated. Here is the action logs when it

  1. Created the labels - log.
  2. It ran in the next commit updating label but no change is done - log.

Enhance issue diff algorithm

Currently the main algorithm works by pulling down all labels on the repos and open the labels.json file. It then loops over the labels.json and does two main things

  1. If it doesn't already exist in the repo, create the label.
  2. If it does, update it no matter what.

Then it filters out all of the labels from the old labels and all that remain need to be deleted.


What I think should be implemented instead of this is an algorithm that diffs the labels and will only send up updates for what it needs to do to get to the state of the labels.json

With this, say I remove a label from labels.json, then the only task done would be to remove that one label from the repo and not touch any other label.

No such file or directory, open '/github/workspace/.github/labels.json'

I have created my labels.json file inside of the appropriate /.github/ directory, but when I run the action, I get the following error message:

(node:1) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, open '/github/workspace/.github/labels.json'
    at Object.openSync (fs.js:439:3)
    at Object.readFileSync (fs.js:344:35)
    at run (/index.js:15:33)
     at process._tickCallback (internal/process/next_tick.js:68:7)

It seems it is looking for the file in /github/workspace/.github/labels.json for some reason. Is it possible the GITHUB_WORKSPACE variable can be different for various repos? https://github.com/lannonbr/issue-label-manager-action/blob/master/index.js#L8-L12

Edit: if it helps, here's the test repo I'm using for this: https://github.com/chrisblakley/Actions-Again/commit/23a9e0dd5c48b343a840dab577ccf9eee7a2703f/checks

Support yaml config format

Could you support yaml as a valid configuration format for defining labels? It's friendlier to work with than json, in terms of both causing fewer git conflicts and being the same format as other .github/ configuration files.

Node 16 update

The action shows warnings about the imminent deprecation of node12 actions. any chance this'll be updated soon?

sp/gr repo about

GitHub Action to declaratively setup labels across repos
->
GitHub Action to declaratively set up labels across repos

Label prefix that action doesn't touch

This action is super promising, but this is giving me headaches:

... and will delete any other labels.

We tend to have a prefix for labels like topic/* that is dynamically used by contributors to group and collect related issues. The labels are created ad hoc, and are regularly removed when no labels are connected any more.

It would be awesome if the action could handle such a "wildcard" label and would not delete such labels. (It could, if set in the configuration, update the color though to fix manual mistaked that were made when creating the labels).

Bug: You have triggered an abuse detection mechanism.

Heya guys, we have hit an issue because our config has 100+ labels which we use across multiple repos. To ensure they are sync'ed up we used your application until recently, where we have this issue:

(node:2624) UnhandledPromiseRejectionWarning: HttpError: You have triggered an abuse detection mechanism. Please wait a few minutes before you try again. at /home/runner/work/_actions/lannonbr/issue-label-manager-action/2.0.0/lib/index.js:86:941 at processTicksAndRejections (internal/process/task_queues.js:93:5)

We believe that the simple solution would be to check if the label is already built, then skip it. This would allow us to run the command a couple of times to generate the entire set.

"Validation Failed" for each request, description missing on new label

I set this up here: citycide/trilogy/.github/workflows/update-issue-labels.yml

On the original run, all the existing labels remained as they were. A newly added one (called zzz: testing) for testing purposes was created but the description field is empty.

It seems the request sent for every label fails with the following message:

HttpError: Validation Failed

Full log here: https://github.com/citycide/trilogy/runs/204987665#step:3:30

Allow color hexcodes with hash symbol

A user submitted a bug that when he inputted a label that had a color field that was prepended with a hash (#), it said in the log it was created but it actually wasn't created because GitHub expects the color without the #.

[
  { "name": "test", "color": "#f00ff0", "description": "test label" }
]

I will shortly create a fix to resolve this so if the string in the labels.json file has a hash or not, it will function as expected.

Errors on v4.0.0

Since the upgrade to v4.0.0 we've seen the action throw a very uninformative error, it appears to just print the contents of the lib/index.js file. Our configuration works just fine on v3.0.0.

Do you have any clue what might be going on?

Support renaming labels

If a label was renamed the old gets deleted - all linked issues will be lost.

It would be great to support renaming of labels.

Error in Private Repo

I tried running this job in a private repository.

I received this error message in my workflow
image

In my public template repo this is working just fine.

What can I do? Is there a way to fix this? Any ideas?

Thank you

UnhandledPromiseRejectionWarning

I ran into this here: https://github.com/oalders/changelog-generator/pull/1/checks?check_run_id=242518473

It was supposed to set up 3 default labels. Two of them already existed, albeit with different letter casing. The delete worked, but only one label Hacktoberfest existed. Bug and Enhancement did not get created.

Run lannonbr/issue-label-manager-action@master
[Action] Deleting Label: bug
[Action] Deleting Label: duplicate
[Action] Deleting Label: enhancement
[Action] Deleting Label: good first issue
[Action] Deleting Label: help wanted
[Action] Deleting Label: invalid
[Action] Deleting Label: question
[Action] Deleting Label: wontfix
[Action] Creating Label: Bug
[Action] Creating Label: Enhancement
[Action] Creating Label: Hacktoberfest
(node:2745) UnhandledPromiseRejectionWarning: HttpError: Validation Failed
    at /home/runner/work/_actions/lannonbr/issue-label-manager-action/master/lib/index.js:86:941
    at processTicksAndRejections (internal/process/task_queues.js:89:5)
    at async /home/runner/work/_actions/lannonbr/issue-label-manager-action/master/lib/index.js:202:1214
(node:2745) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:2745) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:2745) UnhandledPromiseRejectionWarning: HttpError: Validation Failed
    at /home/runner/work/_actions/lannonbr/issue-label-manager-action/master/lib/index.js:86:941
    at processTicksAndRejections (internal/process/task_queues.js:89:5)
    at async /home/runner/work/_actions/lannonbr/issue-label-manager-action/master/lib/index.js:202:1214
(node:2745) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)

Setup ability to propogate label list across entire orgs

For GitHub orgs that share a list of labels across all of the repos in their org, I could enhance this to store the JSON file in one repo and then propagate changes out across all of the repos.

As well, maybe in the JSON you can declare what repos in the org you want it to deploy to.

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.