Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/meilleursagents/comment-on-diff
Add a comment on a PR depending on the diff.
https://github.com/meilleursagents/comment-on-diff
Last synced: 3 days ago
JSON representation
Add a comment on a PR depending on the diff.
- Host: GitHub
- URL: https://github.com/meilleursagents/comment-on-diff
- Owner: MeilleursAgents
- License: mit
- Created: 2020-09-15T07:59:26.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2025-01-08T18:49:34.000Z (6 days ago)
- Last Synced: 2025-01-08T19:41:49.574Z (6 days ago)
- Language: Python
- Size: 135 KB
- Stars: 0
- Watchers: 19
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Codeowners: CODEOWNERS
Awesome Lists containing this project
README
# Comment-on-diff
This github action adds a comment on a pull request depending on which files are modified.
## Usage
To use it you need a github workflow like this:
```
name: Notices
on: [pull_request]
jobs:
build:
name: Send notices
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Fetch branches
run: |
git fetch --no-tags --prune --depth=100 origin "+refs/heads/${BASE}:refs/remotes/origin/${BASE}"
git fetch --no-tags --prune --depth=100 origin "+refs/heads/${HEAD}:refs/remotes/origin/${HEAD}"
env:
BASE: ${{ github.base_ref }}
HEAD: ${{ github.head_ref }}
- name: Comment on diff
uses: MeilleursAgents/comment-on-diff@master
with:
base: ${{ github.event.pull_request.base.sha }}
head: ${{ github.event.pull_request.head.sha }}
github_token: ${{ secrets.GITHUB_TOKEN }}
```## Configuration
You need a config file named `.github/comment-on-diff.yaml`, wich is a YAML dict where keys are paths regexes and value are the message to send.
Example:
```
main.py: You have changed the main.py file, don't forget to run the linter.
some/folder: Any modification on this folder implies you agree with something.
.+/a?b.py: hey looks at that regex!
```With this a modification on those files will trigger a comment with the corresponding message:
* `main.py`: "You have changed…"
* `some/folder/any/file`: "Any modification…"
* `something/ab.py`: "hey…"
* `somethingelse/very/far/away/b.py`: "hey…"Beware that the regex is matched from the start of the file path, so `ab?c.py` would match `abc.py` but not `somewhere/abc.py`.
The messages can be on [multiple lines](https://adminswerk.de/multi-line-string-yaml-ansible-I/) and can use markdown.
The action takes care of not sending twice the same message, to not spam the PR.
### Anti match
You can also trigger a comment when a file is **not** modified.
For that you need to use the extended config structure, like this:
```
CHANGELOG.md:
msg: You need to edit the changelog
absent: true
```This configuration will trigger a comment when no diff is found for "CHANGELOG.md".