https://github.com/codytseng/auto-comment-merge-conflicts
Github Action to automatically add a comment (and a label) to alert developers when there are merge conflicts
https://github.com/codytseng/auto-comment-merge-conflicts
auto-comment auto-label github-actions merge-conflicts
Last synced: 10 months ago
JSON representation
Github Action to automatically add a comment (and a label) to alert developers when there are merge conflicts
- Host: GitHub
- URL: https://github.com/codytseng/auto-comment-merge-conflicts
- Owner: CodyTseng
- License: mit
- Created: 2023-01-06T13:47:23.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-05-15T03:33:52.000Z (about 2 years ago)
- Last Synced: 2025-05-31T15:53:54.418Z (about 1 year ago)
- Topics: auto-comment, auto-label, github-actions, merge-conflicts
- Language: TypeScript
- Homepage:
- Size: 884 KB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: CODEOWNERS
Awesome Lists containing this project
README
# auto-comment-merge-conflicts
> Github Action to automatically add a comment (and a label) to alert developers when there are merge conflicts
## Purpose
This action checks all unlocked open Pull Requests for merge conflicts and add a comment (and a label) if need. When a conflict is resolved the comment (and the label) is automatically removed.

## Usage
```
name: Auto Comment Merge Conflicts
on: push
permissions:
pull-requests: write
jobs:
auto-comment-merge-conflicts:
runs-on: ubuntu-latest
steps:
- uses: codytseng/auto-comment-merge-conflicts@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
comment-body: "Merge Conflict"
wait-ms: 3000
max-retries: 5
label-name: conflict
ignore-authors: dependabot,otherAuthor
```
### List of input options
| input | description | required | default |
| :------------- | :------------------------------------------------------------ | :------: | :------------- |
| token | GitHub token | true | |
| comment-body | Comment body | false | Merge Conflict |
| wait-ms | Milliseconds between retries | false | 3000 |
| max-retries | The number of retries when a PR mergeable status is `UNKNOWN` | false | 5 |
| label-name | Label name | false | |
| ignore-authors | Ignore some author's PR | false | |
### List of output options
| input | description |
| :------------------ | :-------------------------------------------- |
| new-conflicting-prs | List of all new conflicting PRs (json string) |
| new-mergeable-prs | List of all new mergeable PRs (json string) |
The type of PR:
```
{
id: string;
number: number; // Identifies the pull request number.
title: string; // Identifies the pull request title.
url: string; // The HTTP URL for this pull request.
headRefName: string; // Identifies the name of the head Ref associated with the pull request, even if the ref has been deleted.
baseRefName: string; // Identifies the name of the base Ref associated with the pull request, even if the ref has been deleted.
}
```
## How does it work?
1. Get all unlocked open PRs. (Will wait `${wait-ms}` ms and retry if it contains a PR with `UNKNOWN` mergeable status.)
2. If the mergeable status of PR is `CONFLICTING` and this PR has no `${comment-body}` comments, a `${comment-body}` comment will be automatically added.
3. If the mergeable status of PR is `MERGEABLE` and this PR has a `${comment-body}` comment, the comment will be automatically removed.