- Notifications
You must be signed in to change notification settings - Fork15
A GitHub Action to suggest removal of non-organization members from CODEOWNERS files
License
github/cleanowners
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Cleanowners is a GitHub Action that is designed to help keepCODEOWNERS
files current by removing users that are no longer a part of the organization. This is helpful for companies that are looking to remove outdated information in theCODEOWNERS
file. This action can be paired with otherCODEOWNERS
related actions to suggest new owners or lintCODEOWNERS
files to ensure accuracy.
This action was developed by the GitHub OSPO for our own use and developed in a way that we could open source it that it might be useful to you as well! If you want to know more about how we use it, reach out in an issue in this repository.
If you need support using this project or have questions about it, pleaseopen up an issue in this repository. Requests made directly to GitHub staff or support team will be redirected here to open an issue. GitHub SLA's and support/services contracts do not apply to this repository.
All feedback regarding our GitHub Actions, as a whole, should be communicated throughissues on our github-ospo repository.
- Create a repository to host this GitHub Action or select an existing repository.
- Select a best fit workflow file from theexamples below.
- Copy that example into your repository (from step 1) and into the proper directory for GitHub Actions:
.github/workflows/
directory with the file extension.yml
(ie..github/workflows/cleanowners.yml
) - Edit the values (
ORGANIZATION
,EXEMPT_REPOS
) from the sample workflow with your information. - Also edit the value for
GH_ENTERPRISE_URL
if you are using a GitHub Server and not using github.com. For github.com users, don't put anything in here. - Update the value of
GH_TOKEN
. Do this by creating aGitHub API token with permissions to read the repository/organization and write issues or pull requests. Then take the value of the API token you just created, andcreate a repository secret where the name of the secret isGH_TOKEN
and the value of the secret the API token. It just needs to match between when you create the secret name and when you refer to it in the workflow file. - Commit the workflow file to the default branch (often
master
ormain
) - Wait for the action to trigger based on the
schedule
entry or manually trigger the workflow as shown in thedocumentation.
Below are the allowed configuration options:
This action can be configured to authenticate with GitHub App Installation or Personal Access Token (PAT). If all configuration options are provided, the GitHub App Installation configuration has precedence. You can choose one of the following methods to authenticate:
field | required | default | description |
---|---|---|---|
GH_APP_ID | True | "" | GitHub Application ID. Seedocumentation for more details. |
GH_APP_INSTALLATION_ID | True | "" | GitHub Application Installation ID. Seedocumentation for more details. |
GH_APP_PRIVATE_KEY | True | "" | GitHub Application Private Key. Seedocumentation for more details. |
GITHUB_APP_ENTERPRISE_ONLY | False | false | Set this input totrue if your app is created in GHE and communicates with GHE. |
field | required | default | description |
---|---|---|---|
GH_TOKEN | True | "" | The GitHub Token used to scan the repository. Must have read access to all repository you are interested in scanning. |
field | required | default | description |
---|---|---|---|
GH_ENTERPRISE_URL | False | "" | TheGH_ENTERPRISE_URL is used to connect to an enterprise server instance of GitHub. github.com users should not enter anything here. |
ORGANIZATION | Required to haveORGANIZATION orREPOSITORY | The name of the GitHub organization which you want this action to work from. ie. github.com/github would begithub | |
REPOSITORY | Required to haveORGANIZATION orREPOSITORY | The name of the repository and organization which you want this action to work from. ie.github/cleanowners or a comma separated list of multiple repositoriesgithub/cleanowners,super-linter/super-linter | |
EXEMPT_REPOS | False | "" | These repositories will be exempt from this action. ex: If my org is set togithub then I might want to exempt a few of the repos but get the rest by settingEXEMPT_REPOS togithub/cleanowners,github/contributors |
DRY_RUN | False | False | If set to true, this action will not create any pull requests. It will only log the repositories that could have theCODEOWNERS file updated. This is useful for testing or discovering the scope of this issue in your organization. |
ISSUE_REPORT | False | False | If set to true, this action will create an issue in the repository with the report on the repositories that had users removed from theCODEOWNERS file. |
---name:Weekly codeowners cleanupon:workflow_dispatch:schedule: -cron:"3 2 1 * *"permissions:contents:readjobs:cleanowners:name:cleanownersruns-on:ubuntu-latestpermissions:issues:writesteps: -name:Run cleanowners actionuses:github/cleanowners@v1env:GH_TOKEN:${{ secrets.GH_TOKEN }}ORGANIZATION:<YOUR_ORGANIZATION_GOES_HERE>
---name:Weekly codeowners cleanupon:workflow_dispatch:schedule: -cron:"3 2 1 * *"permissions:contents:readjobs:cleanowners:name:cleanownersruns-on:ubuntu-latestpermissions:issues:writesteps: -name:Run cleanowners actionuses:github/cleanowners@v1env:GH_TOKEN:${{ secrets.GH_TOKEN }}ORGANIZATION:<YOUR_ORGANIZATION_GOES_HERE>EXEMPT_REPOS:"org_name/repo_name_1, org_name/repo_name_2"ISSUE_REPORT:true -name:Create issueuses:peter-evans/create-issue-from-file@v5with:title:Cleanowners Reportcontent-filepath:./report.mdassignees:<YOUR_GITHUB_HANDLE_HERE>token:${{ secrets.GITHUB_TOKEN }}
You can authenticate as a GitHub App Installation by providing additional environment variables. IfGH_TOKEN
is set alongside these GitHub App Installation variables, theGH_TOKEN
will be ignored and not used.
---name:Weekly codeowners cleanup via GitHub Appon:workflow_dispatch:schedule: -cron:"3 2 1 * *"permissions:contents:readjobs:cleanowners:name:cleanownersruns-on:ubuntu-latestpermissions:issues:writesteps: -name:Run cleanowners actionuses:github/cleanowners@v1env:GH_APP_ID:${{ secrets.GH_APP_ID }}GH_APP_INSTALLATION_ID:${{ secrets.GH_APP_INSTALLATION_ID }}GH_APP_PRIVATE_KEY:${{ secrets.GH_APP_PRIVATE_KEY }}ORGANIZATION:<YOUR_ORGANIZATION_GOES_HERE>EXEMPT_REPOS:"org_name/repo_name_1, org_name/repo_name_2"
- Make sure you have at least Python3.11 installed
- Copy
.env-example
to.env
- Fill out the
.env
file with atoken from a user that has access to the organization (listed below). Tokens should have at least write:org and write:repository access. - Fill out the
.env
file with the configuration parameters you want to use pip3 install -r requirements.txt
- Run
python3 ./cleanowners.py
, which will output everything in the terminal
Looking for more resources for your open source program office (OSPO)? Check out thegithub-ospo
repository for a variety of tools designed to support your needs.
About
A GitHub Action to suggest removal of non-organization members from CODEOWNERS files
Resources
License
Code of conduct
Contributing
Security policy
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Contributors5
Uh oh!
There was an error while loading.Please reload this page.