Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yrtimid/github-codewatchers
GitHub Action that triggers notifications about changed files to a list of subscribers.
https://github.com/yrtimid/github-codewatchers
actions codeowners github notify
Last synced: 5 days ago
JSON representation
GitHub Action that triggers notifications about changed files to a list of subscribers.
- Host: GitHub
- URL: https://github.com/yrtimid/github-codewatchers
- Owner: yrtimiD
- License: mit
- Created: 2024-01-12T19:29:43.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-07-14T13:12:21.000Z (4 months ago)
- Last Synced: 2024-07-15T12:39:36.796Z (4 months ago)
- Topics: actions, codeowners, github, notify
- Language: TypeScript
- Homepage:
- Size: 1.65 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# github-codewatchers Commit notifier
> GitHub Action that triggers notifications about changed files to a list of subscribers.
## Configuration
Subscriptions are managed in a [CODEOWNERS](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners) like file where file patterns are associated with users. You can use standard `.github/CODEOWNERS` file or make a new one called `.github/CODEWATCHERS` (can use any name) to have a better configuration flexibility.### Inputs
* `GITHUB_TOKEN` (required) - token for interaction with GitHub API, standard GITHUB_TOKEN secret provided to each workflow is good enough
* `codewatchers` (optional) - location of the subscriptions file, default is ".github/CODEWATCHERS"
* `codewatchers_ref` (optional) - the ref to use when loading the CODEWATCHERS file, default is github.ref
* `ignore_own` (optional) - toggles if committer will get notifications for own commits (boolean, default is "true")
* `sha_from` and `sha_to` (required) - commits range to analize. Usually these are taken from the [push](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#push) event (see example below)
* `aggregate_files_limit` (optional) - Limit after which files list will be replaced with aggregated summary message. (integer, default is 20)
* `aggregate_notifications_limit` (optional) - Limit after which many notifications will be replaces with a single aggregated summary message (for each distinct group of subscribers). (integer, default is 5)Action doesn't requires repository checkout, all operations are done via GitHub API
```yaml
name: Commit Notify
on: push
jobs:
get-notifications:
runs-on: ubuntu-latest
steps:
- name: Check commits
id: check
uses: yrtimiD/github-codewatchers@v1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
codewatchers: '.github/CODEWATCHERS'
codewatchers_ref: 'main'
ignore_own: true
sha_from: ${{ github.event.before }}
sha_to: ${{ github.event.after }}
aggregate_files_limit: 20
aggregate_notifications_limit: 5
outputs:
notifications: ${{ steps.check.outputs.notifications }}
```### Output
If any commit has files matched to subsciption rules - action will output an array of watchers (as simplified [GitHub API User](https://docs.github.com/en/rest/users/users?apiVersion=2022-11-28#get-a-user)) and commit (as simplified [GitHub API Commit](https://docs.github.com/en/rest/commits/commits?apiVersion=2022-11-28#get-a-commit)) object.Simplified version of output looks next (only most useful fields are shown):
```json
{
"commit": {
"sha": "5fd3a8a657f7d78b8e8cdb2747585b24607f7e05",
"commit": {
"message": "testing",
"author": {
"name": "Example User",
"email": "[email protected]",
"date": "2024-04-13T08:00:00Z"
},
"committer": {
"name": "Example User",
"email": "[email protected]",
"date": "2024-04-13T08:00:00Z"
}
},
"html_url": "https://github.com/example/example/commit/5fd3a8a657f7d78b8e8cdb2747585b24607f7e05",
"stats": {
"total": 2,
"additions": 1,
"deletions": 1
},
"files": [
{
"filename": "some/file/was/changed.txt",
"status": "modified",
"additions": 1,
"deletions": 1,
"changes": 2,
"blob_url": "https://github.com/example/example/blob/8b61fc1be2ebe2cfe5102587f55ffabd25a58fa5/some%2Ffile%2Fwas%2Fchanged.txt",
"raw_url": "https://github.com/example/example/raw/8b61fc1be2ebe2cfe5102587f55ffabd25a58fa5/some%2Ffile%2Fwas%2Fchanged.txt"
}
]
},
"watchers": [
{
"login": "somewatcher",
"name": "Some Watcher",
"email": "[email protected]"
}
]
}
```## Usage Example
See full workflow example in [.github/workflows/commit-notify.yml](.github/workflows/commit-notify.yml/)Example of `.CODEWATCHERS` file
```
*.md [email protected]
*.sql [email protected]
package.json @somewatcher
```## Known limitations
* Only up to 3000 files from each commit can be matched (Limitation of [Get a commit](https://docs.github.com/en/rest/commits/commits?apiVersion=2022-11-28#get-a-commit) GitHub API )