mszostok/codeowners-validator

Document how to configure GitHub action

Closed this issue · 2 comments

Description

We have multiple outside contributors added to a github org repo. The github org does not contain the outside contributors and so complains even tho we have OWNER_CHECKER_IGNORED_OWNERS set.

Expected result

It should ignore the users that are outside contributors.

Actual result

==> Executing Valid Owner Checker (1.05608306s)
    [err] line 19: User "@user1" is not a member of the organization
    [err] line 19: User "@user2" is not a member of the organization
    [err] line 19: User "@user3" is not a member of the organization

Steps to reproduce

.github/CODEOWNERS

* @user1 @user2 @user3 @githuborg/otherteam

.github/workflows/validate-codeowners.yml

name: Validate Codeowners
on:
  pull_request:

jobs:
  validate-codeowners:
    runs-on: ubuntu-latest
    env:
      OWNER_CHECKER_IGNORED_OWNERS: "@user1,@user2,@user3"
    steps:
    - name: "Checkout source code at current commit"
      uses: actions/checkout@v2
    - uses: mszostok/codeowners-validator@v0.6.0
      with:
        checks: "syntax,owners,duppatterns"
        github_access_token: "${{ secrets.CODE_OWNER_VALIDATION }}"

Troubleshooting

Tried OWNER_CHECKER_IGNORED_OWNERS

What are some ways around this besides disabling the owners check ?

Hi @nitrocode

Thanks for reporting that. It's a problem with workflow syntax. You need to define it as action argument, not enviromnet variable, see:

name: Validate Codeowners
on:
  pull_request:

jobs:
  validate-codeowners:
    runs-on: ubuntu-latest
    steps:
    - name: "Checkout source code at current commit"
      uses: actions/checkout@v2
    - uses: mszostok/codeowners-validator@v0.6.0
      with:
        checks: "syntax,owners,duppatterns"
        github_access_token: "${{ secrets.CODE_OWNER_VALIDATION }}"
        owner_checker_ignored_owners: "@user1,@user2,@user3" # you need to define them as action argument

The codeowners validator can be used directly as binary e.g. locally or on other CI system and also as GitHub Action.

When it is used as a GitHub action, the configuration needs to be specified as action arguments. This is the preferred way. You can also use the env variable but then you need to add INPUT_ prefix which GitHub adds by default, so on GitHub action OWNER_CHECKER_IGNORED_OWNERS becomes INPUT_OWNER_CHECKER_IGNORED_OWNERS.

I will update GitHub action documentation to make it clear also for others.

Cheers!

[NOTE] relates to: #73