Skip to content

Commit 4adb7be

Browse files
committed
Add docs for GitHub action (#32)
1 parent b9dc913 commit 4adb7be

4 files changed

Lines changed: 92 additions & 33 deletions

File tree

README.md

Lines changed: 42 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,48 @@ The Codeowners Validator project validates the GitHub [CODEOWNERS](https://help.
1515

1616
![usage](./docs/assets/usage.svg)
1717

18+
## Usage
19+
20+
#### Docker
21+
22+
```bash
23+
export GH_TOKEN=<your_token>
24+
docker run --rm -v $(pwd):/repo -w /repo \
25+
-e REPOSITORY_PATH="." \
26+
-e GITHUB_ACCESS_TOKEN="$GH_TOKEN" \
27+
-e EXPERIMENTAL_CHECKS="notowned" \
28+
-e OWNER_CHECKER_REPOSITORY="org-name/rep-name" \
29+
mszostok/codeowners-validator:v0.4.0
30+
```
31+
32+
#### Command line
33+
34+
```bash
35+
export GH_TOKEN=<your_token>
36+
env REPOSITORY_PATH="." \
37+
GITHUB_ACCESS_TOKEN="$GH_TOKEN" \
38+
EXPERIMENTAL_CHECKS="notowned" \
39+
OWNER_CHECKER_REPOSITORY="org-name/rep-name" \
40+
codeowners-validator
41+
```
42+
43+
#### GitHub Action
44+
45+
```yaml
46+
- uses: mszostok/codeowners-validator@v0.4.0
47+
with:
48+
checks: "files,owners,duppatterns"
49+
experimental_checks: "notowned"
50+
# GitHub access token is required only if the `owners` check is enabled
51+
github_access_token: "${{ secrets.OWNERS_VALIDATOR_GITHUB_SECRET }}"
52+
```
53+
54+
Check [this](./docs/gh-action.md) document for more information about GitHub Action.
55+
56+
----
57+
58+
Check the [Configuration](#configuration) section for more info on how to enable and configure given checks.
59+
1860
## Installation
1961
2062
It's highly recommended to install a fixed version of ` codeowners-validator`. Releases are available on the [releases page](https://github.com/mszostok/codeowners-validator/releases).
@@ -47,38 +89,6 @@ You can install `codeowners-validator` with `env GO111MODULE=on go get -u github
4789
4890
This will put `codeowners-validator` in `$(go env GOPATH)/bin`
4991

50-
## Usage
51-
52-
#### Docker
53-
54-
```bash
55-
export GH_TOKEN=<your_token>
56-
docker run --rm -v $(pwd):/repo -w /repo \
57-
-e REPOSITORY_PATH="." \
58-
-e GITHUB_ACCESS_TOKEN="$GH_TOKEN" \
59-
-e EXPERIMENTAL_CHECKS="notowned" \
60-
-e OWNER_CHECKER_REPOSITORY="org-name/rep-name" \
61-
mszostok/codeowners-validator:v0.4.0
62-
```
63-
64-
#### Command line
65-
66-
```bash
67-
export GH_TOKEN=<your_token>
68-
env REPOSITORY_PATH="." \
69-
GITHUB_ACCESS_TOKEN="$GH_TOKEN" \
70-
EXPERIMENTAL_CHECKS="notowned" \
71-
OWNER_CHECKER_REPOSITORY="org-name/rep-name" \
72-
codeowners-validator
73-
```
74-
75-
#### GitHub Action
76-
77-
Coming soon 😎 Stay tuned!
78-
79-
80-
Check the [Configuration](#configuration) section for more info on how to enable and configure given checks.
81-
8292
## Configuration
8393

8494
Use the following environment variables to configure the application:

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ author: "szostok.mateusz@gmail.com"
44

55
inputs:
66
github_access_token:
7-
description: "The GitHub access token. Instruction for creating a token can be found here. If not provided then validating owners functionality could not work properly, e.g. you can reach the API calls quota or if you are setting GitHub Enterprise base URL then an unauthorized error can occur."
7+
description: "The GitHub access token. Instruction 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. If not provided then validating owners functionality could not work properly, e.g. you can reach the API calls quota or if you are setting GitHub Enterprise base URL then an unauthorized error can occur."
88
required: false
99

1010
github_base_url:

docs/assets/action-output.png

188 KB
Loading

docs/gh-action.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<p align="center">
2+
<h3 align="center">GitHub Action for CODEOWNERS Validator</h3>
3+
<p align="center">Ensures the correctness of your CODEOWNERS file.</p>
4+
<p align="center">
5+
<a href="/LICENSE"><img alt="Software License" src="https://img.shields.io/badge/license-Apache-brightgreen.svg?style=flat-square"></a>
6+
</p>
7+
</p>
8+
9+
---
10+
11+
The [Codeowners Validator](https://github.com/mszostok/codeowners-validator) is available as a GitHub Action.
12+
13+
<p align="center">
14+
<img src="https://raw.githack.com/mszostok/codeowners-validator/master/docs/assets/action-output.png" width="600px" alt="demo">
15+
</p>
16+
17+
18+
## Usage
19+
20+
Create a workflow (eg: `.github/workflows/sanity.yml` see [Creating a Workflow file](https://help.github.com/en/articles/configuring-a-workflow#creating-a-workflow-file))
21+
22+
```yaml
23+
name: "Codeowners Validator"
24+
25+
on:
26+
schedule:
27+
# Runs at 08:00 UTC every day
28+
- cron: '0 8 * * *'
29+
30+
jobs:
31+
sanity:
32+
runs-on: ubuntu-latest
33+
steps:
34+
# Checks-out your repository, which is validated in the next step
35+
- uses: actions/checkout@v2
36+
- name: GitHub CODEOWNERS Validator
37+
uses: mszostok/codeowners-validator@v0.4.0
38+
with:
39+
checks: "files,owners,duppatterns"
40+
experimental_checks: "notowned"
41+
# GitHub access token is required only if the `owners` check is enabled
42+
github_access_token: "${{ secrets.OWNERS_VALIDATOR_GITHUB_SECRET }}"
43+
```
44+
45+
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.
46+
47+
> **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.
48+
49+
<!--- example repository when failed -->

0 commit comments

Comments
 (0)