Ensures the correctness of your CODEOWNERS file.
The Codeowners Validator is available as a GitHub Action.
Create a workflow (eg: .github/workflows/sanity.yml
see Creating a Workflow file)
name: "Codeowners Validator"
on:
schedule:
# Runs at 08:00 UTC every day
- cron: '0 8 * * *'
jobs:
sanity:
runs-on: ubuntu-latest
steps:
# Checks-out your repository, which is validated in the next step
- uses: actions/checkout@v2
- name: GitHub CODEOWNERS Validator
uses: mszostok/codeowners-validator@v0.4.0
with:
checks: "files,owners,duppatterns"
experimental_checks: "notowned"
# GitHub access token is required only if the `owners` check is enabled
github_access_token: "${{ secrets.OWNERS_VALIDATOR_GITHUB_SECRET }}"
The best is to run this as a cron job and not only if you applying changes to CODEOWNERS file itself, e.g. the CODEOWNERS file can be invalidate when you removing someone from the organization.
Note: To execute
owners
check you need to create a GitHub token and store it as a secret in your repository, see "Creating and storing encrypted secrets.". Token requires only read-only scope for your repository.