CodeMention is a GitHub Action that mentions users and teams who subscribe to certain file changes on pull requests. See in pull requests in the codemention-test repo for examples of how this looks like.
This is similar to Codenotify, but this retrieves the list of files changed via GitHub's REST API instead of using actions/checkout to clone the repo (which can be problematic on large repos).
To use this GitHub Action, add a .github/codemention.yml file to your repo that contains mentions/notifications rules.
An example looks like:
rules:
- patterns: ['config/**']mentions: ['sysadmin']
- patterns: ['db/migrate/**']mentions: ['cto', 'dba']
- patterns: ['.github/**', 'spec/*.rb']mentions: ['ci']See the Configuration interface in src/configuration.ts for possible options.
Add a .github/workflows/codemention.yml file to your repo with the following:
name: codementionon:
pull_request_target:
types: [opened, synchronize, ready_for_review]jobs:
codemention:
runs-on: ubuntu-latestpermissions:
contents: readpull-requests: writesteps:
- uses: tobyhs/codemention@v2with:
githubToken: ${{ secrets.GITHUB_TOKEN }}Due to GitHub Actions access restrictions on caching, a pull request typically cannot save a cache that other pull requests can use. To work around this, you can create a workflow that saves the dpendency cache in the default branch scope with a file like the following (replace main with your default branch):
name: 'codemention: populate cache'on:
push:
branches:
- mainworkflow_dispatch:
jobs:
codemention_populate_cache:
runs-on: ubuntu-lateststeps:
- uses: tobyhs/codemention/populate-cache@v2In order for CodeMention to mention teams, you need to use a GitHub personal access token that has organization permissions to read members.
Replace the githubToken input with your personal access token.