Skip to content

Warning

You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?

update codeowners

Actions
generate and update GitHub s CODEOWNERS file based on the git fame of files
v0.1.0
Star (7)

update code owners action

GitHub Workflow Status (branch) Renovate Status CodeFactor GitHub License GitHub last commit

This is a GitHub Action that uses git-fame to generate and update GitHub's CODEOWNERS file based on the git fame of files.

What does it do?

GitHub's CODEOWNERS feature doesn't provide any method for keeping the code owners list updated automatically. This action solves this by determining code owners based on the git fame of each file. Authors don't have to be asked for their addition based on subjective criteria anymore.

Inputs

distribution

The distribution input defines the minimum percentage of code lines that are required for a contributor to being considered a code owner. The default uses 20% of ownership. Set it to any integer without the percent character to override the default.

path

The path defines the path to the CODEOWNERS file. The default uses the path to the .github directory.

granular

By default, this action checks all files in the root, but groups recursive files into their parent directories. Set this input to any non-zero value (e.g. true) to enable full coverage of all recursive files.

Example

This is a typical example for a pull request workflow. It should suffice to trigger it on few event types of pull request event only. That also gives the author the possibility to remove themselves from the owners list optionally.

name: codeowners

on:
  pull_request_target:
    branches:
      - master
    types:
      - ready_for_review
      - review_request_removed
      - reopened
      - labeled

jobs:
  update:
    runs-on: ubuntu-latest
    steps:
    - name: checkout code
      uses: actions/[email protected]
      with:
        # this only makes sure that forks are built as well
        repository: ${{ github.event.pull_request.head.repo.full_name }}
        ref: ${{ github.head_ref }}
        # the fetch depth 0 (=all) is important
        fetch-depth: 0
        # the token is necessary for checks to rerun after auto commit
        token: ${{ secrets.PAT }}
    - name: update code owners
      uses: gofunky/update-codeowners@master
      with:
        distribution: 25
    - name: commit changed files
      id: committed
      uses: stefanzweifel/[email protected]
      with:
        commit_message: 'chore(meta): update code owners'
        file_pattern: .github/CODEOWNERS
    - uses: christianvuerings/[email protected]
      if: ${{ steps.committed.outputs.changes_detected == 'true' }}
      with:
        labels: owned
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

update codeowners is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.

About

generate and update GitHub s CODEOWNERS file based on the git fame of files
v0.1.0

update codeowners is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.