Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/int128/find-codeowners-action
Find the owners from CODEOWNERS in GitHub Actions
https://github.com/int128/find-codeowners-action
codeowners github-actions
Last synced: 2 months ago
JSON representation
Find the owners from CODEOWNERS in GitHub Actions
- Host: GitHub
- URL: https://github.com/int128/find-codeowners-action
- Owner: int128
- License: apache-2.0
- Created: 2024-03-27T01:37:28.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-05-22T01:52:24.000Z (8 months ago)
- Last Synced: 2024-05-22T22:12:21.590Z (8 months ago)
- Topics: codeowners, github-actions
- Language: TypeScript
- Homepage:
- Size: 1.31 MB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# find-codeowners-action [![ts](https://github.com/int128/find-codeowners-action/actions/workflows/ts.yaml/badge.svg)](https://github.com/int128/find-codeowners-action/actions/workflows/ts.yaml)
This action finds the owners from [CODEOWNERS](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners).
## Getting Started
To find the owners of a file,
```yaml
steps:
- uses: actions/checkout@v4
- id: codeowners
uses: int128/find-codeowners-action@v0
with:
codeowners: CODEOWNERS
path: src/index.ts
```This action reads `CODEOWNERS` file in the working directory,
and finds the owners of `src/index.ts`.If no owner is found, this action returns an empty string.
## Examples
### Notify a workflow run event to the owners
To notify an event to the corresponding owners,
```yaml
on:
workflow_run:
types:
- completedjobs:
notify-workflow-run:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- id: codeowners
uses: int128/find-codeowners-action@v0
with:
codeowners: CODEOWNERS
path: ${{ github.event.workflow.path }}# Something to notify
- uses: slackapi/slack-github-action@v1
with:
channel-id: example
slack-message: |
Hey ${{ steps.codeowners.outputs.owners-without-organization }}, done!
```### Test the coverage of CODEOWNERS
To ensure the all workflows are owned by anyone,
```yaml
jobs:
validate-coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- id: codeowners
uses: int128/find-codeowners-action@v0
with:
codeowners: CODEOWNERS
path: .github/workflows/*
path-glob: true
- if: steps.codeowners.outputs.orphan-files
run: exit 1
```If a file is not owned in CODEOWNERS, this action shows the message.
```console
Warning: File .github/workflows/build.yaml is not owned by anyone
```## Specification
### Inputs
| Name | Default | Description |
| ------------ | ---------- | ------------------------------------------- |
| `codeowners` | (required) | Path of CODEOWNERS |
| `path` | (required) | Path(s) to find the owners (multiline) |
| `path-glob` | false | If true, evaluate `path` as glob pattern(s) |### Outputs
| Name | Description |
| ----------------------------- | ---------------------------------------------------------------------- |
| `owners` | List of owners, separated by space |
| `owners-without-organization` | List of owners in the form of `@user` or `@team`, separated by space |
| `orphan-files` | List of files which are not owned in CODEOWNERS, separated by new line |