-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add missing inputs to action.yml, refactor auth docs (#163)
* Update action.yml * Update golangci-lint installation process * Update docs
- Loading branch information
Showing
7 changed files
with
106 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,15 +38,30 @@ jobs: | |
uses: mszostok/[email protected] | ||
# input parameters | ||
with: | ||
# "The list of checks that will be executed. By default, all checks are executed. Possible values: files,owners,duppatterns,syntax" | ||
checks: "files,owners,duppatterns,syntax" | ||
|
||
# "The comma-separated list of experimental checks that should be executed. By default, all experimental checks are turned off. Possible values: notowned." | ||
experimental_checks: "notowned" | ||
# ==== GitHub Auth ==== | ||
|
||
## ==== PAT ==== | ||
# GitHub access token is required only if the `owners` check is enabled | ||
github_access_token: "${{ secrets.OWNERS_VALIDATOR_GITHUB_SECRET }}" | ||
|
||
## ==== App ==== | ||
# GitHub App ID for authentication. This replaces the github_access_token. | ||
github_app_id: ${{ secrets.APP_ID }} | ||
|
||
# GitHub App Installation ID. Required when github_app_id is set. | ||
github_app_installation_id: ${{ secrets.APP_INSTALLATION_ID }} | ||
|
||
# GitHub App private key in PEM format. Required when github_app_id is set. | ||
github_app_private_key: ${{ secrets.APP_PRIVATE_KEY }} | ||
|
||
# ==== GitHub Auth ==== | ||
|
||
# "The list of checks that will be executed. By default, all checks are executed. Possible values: files,owners,duppatterns,syntax" | ||
checks: "files,owners,duppatterns,syntax" | ||
|
||
# "The comma-separated list of experimental checks that should be executed. By default, all experimental checks are turned off. Possible values: notowned,avoid-shadowing" | ||
experimental_checks: "notowned,avoid-shadowing" | ||
|
||
# The GitHub base URL for API requests. Defaults to the public GitHub API, but can be set to a domain endpoint to use with GitHub Enterprise. | ||
github_base_url: "https://api.github.com/" | ||
|
||
|
@@ -80,7 +95,9 @@ jobs: | |
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](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/#creating-a-token) and store it as a secret in your repository, see ["Creating and storing encrypted secrets."](https://help.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets). Token requires only read-only scope for your repository. | ||
> **Note** | ||
> | ||
> To execute `owners` check you need to create a [GitHub token](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/#creating-a-token) and store it as a secret in your repository, see ["Creating and storing encrypted secrets."](https://help.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets). Token requires only read-only scope for your repository. | ||
|
||
<!--- example repository when failed --> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
[← back to docs](./README.md) | ||
|
||
# GitHub tokens | ||
|
||
The [valid_owner.go](./../internal/check/valid_owner.go) check requires the GitHub token for the following reasons: | ||
|
||
1. Information about organization teams and their repositories is not publicly available. | ||
2. If you set GitHub Enterprise base URL, an unauthorized error may occur. | ||
3. For unauthenticated requests, the rate limit allows for up to 60 requests per hour. Unauthenticated requests are associated with the originating IP address. In a big organization where you have a lot of calls between your infrastructure server and the GitHub site, it is easy to exceed that quota. | ||
|
||
The Codeowners Validator source code is available on GitHub. You can always perform a security audit against its code base and build your own version from the source code if your organization is stricter about the software run in its infrastructure. | ||
|
||
You can either use a [personal access token](#github-personal-access-token) or a [GitHub App](#github-app). | ||
|
||
## GitHub personal access token | ||
|
||
Instructions for creating a token can be found [here](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/#creating-a-token). The minimal scope required for the token is **read-only**, but the definition of this scope differs between public and private repositories. | ||
|
||
#### Public repositories | ||
|
||
For public repositories, select `public_repo` and `read:org`: | ||
|
||
![token-public.png](./assets/token-public.png) | ||
|
||
#### Private repositories | ||
|
||
For private repositories, select `repo` and `read:org`: | ||
|
||
![token-public.png](./assets/token-private.png) | ||
|
||
|
||
## GitHub App | ||
|
||
Here are the steps to create a GitHub App and use it for this tool: | ||
|
||
1. [Create a GitHub App](https://docs.github.com/en/developers/apps/building-github-apps/creating-a-github-app). | ||
> **Note** | ||
> Your app does not need a callback or a webhook URL. | ||
2. Add a read-only permission to the "Members" item of organization permissions. | ||
3. [Install the app in your organization](https://docs.github.com/en/developers/apps/managing-github-apps/installing-github-apps). | ||
4. Done! To authenticate with your app, you need: | ||
|
||
| Name | Description | | ||
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ||
| GitHub App Private Key | PEM-format key generated when the app is installed. If you lost it, you can regenerate it ([docs](https://docs.github.com/en/developers/apps/building-github-apps/authenticating-with-github-apps#generating-a-private-key)). | | ||
| GitHub App ID | Found in the app's "About" page (Organization settings -> Developer settings -> Edit button on your app). | | ||
| GitHub App Installation ID | Found in the URL your organization's app install page (Organization settings -> Github Apps -> Configure button on your app). It's the last number in the URL, ex: `https://github.com/organizations/{my-org}/settings/installations/1234567890`. | | ||
|
||
6. Depends on the usage you need to: | ||
|
||
1. **CLI:** Export them as environment variable: | ||
- `GITHUB_APP_INSTALLATION_ID` | ||
- `GITHUB_APP_ID` | ||
- `GITHUB_APP_PRIVATE_KEY` | ||
|
||
2. [**GitHub Action:**](gh-action.md) Define them as GitHub secrets and use under the `with` property: | ||
|
||
```yaml | ||
- name: GitHub CODEOWNERS Validator | ||
uses: mszostok/[email protected] | ||
with: | ||
# ... | ||
github_app_id: ${{ secrets.APP_ID }} | ||
github_app_installation_id: ${{ secrets.APP_INSTALLATION_ID }} | ||
github_app_private_key: ${{ secrets.APP_PRIVATE_KEY }} | ||
``` |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters