Giter Club home page Giter Club logo

periodic-labeler's Introduction

Periodic Labeler Action

A GitHub action to automatically label all PRs according to file patterns.

๐Ÿ“ Note: The pull_request_target event added to GitHub Actions makes it possible to achieve this without a scheduled workflow. See this post for an example.

Table of Contents

Usage

Action is meant to be run as periodic job. This is needed to workaround issues regarding lack of write access when executed from fork which is a common problem when using https://github.com/actions/labeler.

---
name: Pull request labeler
on:
  schedule:
    - cron: '*/5 * * * *'
jobs:
  labeler:
    runs-on: ubuntu-latest
    steps:
      - uses: paulfantom/periodic-labeler@master
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          GITHUB_REPOSITORY: ${{ github.repository }}
          LABEL_MAPPINGS_FILE: .github/labeler.yml

By default action uses .github/labeler.yml located in repository from GITHUB_REPOSITORY as a source of pattern matchers. This file uses the same schema as in https://github.com/actions/labeler

periodic-labeler's People

Contributors

ilyam8 avatar jclem avatar paulfantom avatar potiuk avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar

periodic-labeler's Issues

Periodic Labeler Exit Code 255 error on every run

We're getting this on every labeler run:

2019-11-28T18:45:34.3846459Z ##[command]/usr/bin/docker run --name quayiopaulfantomperiodiclabelerlatest_b10f13 --label f6cdeb --workdir /github/workspace --rm -e GITHUB_TOKEN -e GITHUB_REPOSITORY -e LABEL_MAPPINGS_FILE -e HOME -e GITHUB_REF -e GITHUB_SHA -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e RUNNER_OS -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e GITHUB_ACTIONS=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/SCPSL-Translations/SCPSL-Translations":"/github/workspace" quay.io/paulfantom/periodic-labeler:latest
2019-11-28T18:45:35.2444794Z ERROR: logging before flag.Parse: F1128 18:45:35.073126       1 main.go:96] yaml: unmarshal errors:
2019-11-28T18:45:35.2458667Z   line 1: cannot unmarshal !!str `README.md` into []string
2019-11-28T18:45:35.2459102Z   line 2: cannot unmarshal !!str `Transla...` into []string
2019-11-28T18:45:35.2459327Z   line 3: cannot unmarshal !!str `Transla...` into []string
2019-11-28T18:45:35.2459535Z   line 4: cannot unmarshal !!str `Transla...` into []string
2019-11-28T18:45:35.2459919Z   line 5: cannot unmarshal !!str `Transla...` into []string
2019-11-28T18:45:35.2460607Z   line 6: cannot unmarshal !!str `Transla...` into []string
2019-11-28T18:45:35.2461018Z   line 7: cannot unmarshal !!str `Transla...` into []string
2019-11-28T18:45:35.2461352Z   line 8: cannot unmarshal !!str `Transla...` into []string
2019-11-28T18:45:35.2461685Z   line 9: cannot unmarshal !!str `Transla...` into []string
2019-11-28T18:45:35.2462110Z   line 10: cannot unmarshal !!str `Transla...` into []string
2019-11-28T18:45:35.2463788Z   line 11: cannot unmarshal !!str `Transla...` into []string
2019-11-28T18:45:35.2464177Z   line 12: cannot unmarshal !!str `Transla...` into []string
2019-11-28T18:45:35.2464454Z   line 13: cannot unmarshal !!str `Transla...` into []string
2019-11-28T18:45:35.2464666Z   line 14: cannot unmarshal !!str `Transla...` into []string
2019-11-28T18:45:35.2464868Z   line 15: cannot unmarshal !!str `Transla...` into []string
2019-11-28T18:45:35.2465226Z   line 16: cannot unmarshal !!str `Transla...` into []string
2019-11-28T18:45:35.2465427Z   line 17: cannot unmarshal !!str `Transla...` into []string
2019-11-28T18:45:35.2465870Z   line 18: cannot unmarshal !!str `Transla...` into []string
2019-11-28T18:45:35.2466085Z   line 19: cannot unmarshal !!str `Transla...` into []string
2019-11-28T18:45:35.2466689Z   line 20: cannot unmarshal !!str `Transla...` into []string
2019-11-28T18:45:35.2466972Z   line 21: cannot unmarshal !!str `Transla...` into []string
2019-11-28T18:45:35.2467303Z   line 22: cannot unmarshal !!str `Transla...` into []string
2019-11-28T18:45:35.2467543Z   line 23: cannot unmarshal !!str `Transla...` into []string
2019-11-28T18:45:35.2467734Z   line 24: cannot unmarshal !!str `Transla...` into []string
2019-11-28T18:45:35.2468057Z   line 25: cannot unmarshal !!str `Transla...` into []string
2019-11-28T18:45:35.2468201Z   line 26: cannot unmarshal !!str `Transla...` into []string
2019-11-28T18:45:35.2468509Z goroutine 1 [running]:
2019-11-28T18:45:35.2468743Z github.com/golang/glog.stacks(0xc00000e000, 0xc00039bc00, 0x66a, 0x6bf)
2019-11-28T18:45:35.2469865Z 	/go/pkg/mod/github.com/golang/[email protected]/glog.go:769 +0xb8
2019-11-28T18:45:35.2470330Z github.com/golang/glog.(*loggingT).output(0x9f4480, 0xc000000003, 0xc0002bf810, 0x9ab8e7, 0x7, 0x60, 0x0)
2019-11-28T18:45:35.2471210Z 	/go/pkg/mod/github.com/golang/[email protected]/glog.go:720 +0x372
2019-11-28T18:45:35.2471595Z github.com/golang/glog.(*loggingT).printDepth(0x9f4480, 0x3, 0x1, 0xc000045f00, 0x1, 0x1)
2019-11-28T18:45:35.2472645Z 	/go/pkg/mod/github.com/golang/[email protected]/glog.go:646 +0x129
2019-11-28T18:45:35.2473074Z github.com/golang/glog.(*loggingT).print(...)
2019-11-28T18:45:35.2475637Z 	/go/pkg/mod/github.com/golang/[email protected]/glog.go:637
2019-11-28T18:45:35.2476210Z github.com/golang/glog.Fatal(...)
2019-11-28T18:45:35.2494402Z 	/go/pkg/mod/github.com/golang/[email protected]/glog.go:1128
2019-11-28T18:45:35.2494998Z main.main()
2019-11-28T18:45:35.2495639Z 	/go/src/github.com/paulfantom/periodic-labeler/main.go:96 +0x4cb
2019-11-28T18:45:35.2509372Z ##[error]Docker run failed with exit code 255

Our repository: https://github.com/northwood-studios/SCPSL-Translations

default config does not seem to work out of the box

I setup periodic labeler on https://github.com/maxandersen/quarkus-nonfork to try and work around action/labeler limits.

But using the default setup I end up with errors when running, see https://github.com/maxandersen/quarkus-nonfork/commit/1f9eececb01eab0fa6cb11ed36c05f7d1b0f6f71/checks?check_suite_id=409946518

ERROR: logging before flag.Parse: F0120 12:26:51.433401       1 main.go:85] GET https://api.github.com/repos/maxandersen/quarkus-nonfork/contents/.github/labeler.yml: 401 Bad credentials []
goroutine 1 [running]:
github.com/golang/glog.stacks(0xc00007c000, 0xc0000cc200, 0x9c, 0xf1)
	/go/pkg/mod/github.com/golang/[email protected]/glog.go:769 +0xb8
github.com/golang/glog.(*loggingT).output(0x9f4480, 0xc000000003, 0xc0000960e0, 0x9abbcf, 0x7, 0x55, 0x0)
	/go/pkg/mod/github.com/golang/[email protected]/glog.go:720 +0x372
github.com/golang/glog.(*loggingT).printDepth(0x9f4480, 0x3, 0x1, 0xc000419ed0, 0x1, 0x1)
	/go/pkg/mod/github.com/golang/[email protected]/glog.go:646 +0x129
github.com/golang/glog.(*loggingT).print(...)
	/go/pkg/mod/github.com/golang/[email protected]/glog.go:637
github.com/golang/glog.Fatal(...)
	/go/pkg/mod/github.com/golang/[email protected]/glog.go:1128
main.main()
	/go/src/github.com/paulfantom/periodic-labeler/main.go:85 +0x33a
##[error]Docker run failed with exit code 255

its basically saying it does not have access which it obviously should have as it is handed the GITHUB secret...

Pagination is not implemented

Unfortunately most of the Github APIs returning collections returns maximum 30 responses. This is documented here https://developer.github.com/v3/#pagination but unfortunately it is not mentioned in the particular APIs that are affected. So when reading https://developer.github.com/v3/pulls/#list-pull-requests it's not at all obvious that pagination is in operation and that you should add another loop through pages.

Periodic labeler does not have pagination implemented, therefore the result is that in big repositories with > 30 PRs only the OLDEST prs will be checked (that's what is the sorting order). If all those 30 PRs are properly labelled, then the plugin will stop working and will not pick any new PRs. There is an interesting behaviour of that - if there are unlabelled old PRs, they will get updated, so - in fact - they will disappear from the "oldest" list and possibly some new PRs that will be checked in the new pass. However once you have 30 oldest, properly labelled PRs, the plugin stops working. That's really annoying and difficult to detect problem - especially if your repo does not have a lot of PRs.

Pagination is easy. It is described here: https://github.com/google/go-github/#pagination

Pull request with a fix follows shortly.

Add `pull_request_target` note to Readme?

๐Ÿ‘‹ Hi! Hubber here. I'm curious if we can add a note to the readme of this repository that pull_request_target as an event is now available, and that this new event can be used safely on public repositories. I've outlined how to do this in this blog post.

Essentially, it could work with basically the exact same Go code this action uses now, but it could run on actual PR events, rather than on a schedule, which (now) unnecessarily churns through users' Actions minutes.

I also want to say that this repo is an extremely clever hack, and I love it ๐Ÿ˜„ Just want to make sure people are aware of the new event.

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.