Skip to content
play

GitHub Action

autolabeler-codeowners

0.1 Latest version

autolabeler-codeowners

play

autolabeler-codeowners

Automatically label PRs based on CODEOWNERS

Installation

Copy and paste the following snippet into your .yml file.

              

- name: autolabeler-codeowners

uses: pratikmallya/[email protected]

Learn more about this action in pratikmallya/autolabeler-codeowners

Choose a version

https://github.com/pratikmallya/autolabeler-codeowners/workflows/build-test/badge.svg?branch=master

autolabeler-codeowners

Adds labels to PR's based on CODEOWNERS. Useful in monorepos where there can be a ton of concurrent users and it might get hard to find the relevant PR for a particular team.

Example usage

The following is a fully functional Github Workflow. Note that a Github Oauth token needs to be added to the Github repo as a Github secret with the name githubToken.

on: [pull_request]
jobs:
  autolabeler-codeowners:
    runs-on: ubuntu-latest
    name: PR + CODEOWNERS Workflows
    steps:
    - uses: actions/checkout@v1
    - name: Add CODEOWNER Label To PR
      uses: pratikmallya/autolabeler-codeowners@releases/v1
      with:
        githubToken: ${{ secrets.githubToken }}

Deployment

The nodejs modules (in ./node_modules) and compiled JS (in ./lib) must be committed to the release branches but NOT to master (to keep master branch clean)

Testing

  • install dev deps using npm install --save-dev
  • run npm run test

Known Limitations

  • no retry logic: In practice not a huge deal as most PR's have multiple pushes and thus the workflow is triggered several times for the same PR.
  • only detects the first 100 files in a PR: This has not been a problem in practice since most PR's only make large changes within code-owned teams. Cross-codeowned, large changes have been rare. If this is a problem, feel free to open a PR/Issue with details!
  • does not work for PR's from forked repos for private repos: this is simply because the action is not triggered by Github so there is realistically no way to fix it. Github promises to fix this by GA

Release Process

(TODO: automate)

  • checkout to the release branch e.g. git checkout -b releases/v1
    1. If release branch already exists, git checkout releases/v1 and then pull in any new changes you need e.g. git merge master
  • uncomment ./node_modules and ./lib from .gitignore, this allows us to commit them
  • run npm prune --production to prune the modules
  • compile JS with npm run build
  • git add lib/ to add any newly generated JS files
  • commit to branch git commit -am "ADD: readying for release"
  • push branch
  • update Github Marketplace