Github Action to automatically add a comment (and a label) to alert developers when there are merge conflicts
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.
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
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 |
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.
}
- Get all unlocked open PRs. (Will wait
${wait-ms}
ms and retry if it contains a PR withUNKNOWN
mergeable status.) - If the mergeable status of PR is
CONFLICTING
and this PR has no${comment-body}
comments, a${comment-body}
comment will be automatically added. - If the mergeable status of PR is
MERGEABLE
and this PR has a${comment-body}
comment, the comment will be automatically removed.