Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
bell

GitHub Action

Codewatchers Commit Notifier

v1.0.4

Codewatchers Commit Notifier

bell

Codewatchers Commit Notifier

Prepares commit notifications by matching changed files with CODEOWNERS rules

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Codewatchers Commit Notifier

uses: yrtimiD/[email protected]

Learn more about this action in yrtimiD/github-codewatchers

Choose a version

github-codewatchers Commit notifier

GitHub Action which helps sending notification about changed files to subscribers.

Configuration

Subscriptions are managed in a CODEOWNERS 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"
  • 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 event (see example below)
  • limit (optional) - maximum number of notifications to produce. If limit exceeded - action will end with a warning and remaining commits will be skipped. (integer, default is 10)

Action doesn't requires repository checkout, all operations are done via GitHub API

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'
           ignore_own: true
           sha_from: ${{ github.event.before }}
           sha_to: ${{ github.event.after }}
		   limit: 10
    outputs:
      notifications: ${{ steps.check.outputs.notifications }}

Output

If any commit has files matched to subsciption rules - action will output an array of watchers (as GitHub API User) and commit (as GitHub API Commit) object.

Simplified version of output looks next (there are more fields):

{
  "commit": {
    "sha": "5fd3a8a657f7d78b8e8cdb2747585b24607f7e05",
    "commit": {
      "message": "testing"
    },
    "html_url": "https://github.com/example/example/commit/5fd3a8a657f7d78b8e8cdb2747585b24607f7e05",
    "author": {
      "login": "somecommitter"
    },
    "committer": {
      "login": "somecommitter"
    },
    "stats": {
      "total": 2,
      "additions": 1,
      "deletions": 1
    },
    "files": [
      {
        "filename": "some/file/was/changed.txt",
        "status": "modified",
        "additions": 1,
        "deletions": 1,
        "changes": 2
      }
    ]
  },
  "watchers": [
    {
      "login": "somewatcher",
      "name": "Some Watcher",
      "email": "[email protected]"
    }
  ]
}

Usage Example

See full example workflow in examples

Known limitations

  • Only up to 3000 files from each commit can be matched (Limitation of Get a commit GitHub API )