-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add comment for merge block workflow
- Loading branch information
1 parent
fd3811e
commit eb72117
Showing
2 changed files
with
38 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,18 +7,48 @@ on: | |
required: false | ||
type: string | ||
default: do not merge | ||
comment: | ||
required: false | ||
type: boolean | ||
default: true | ||
|
||
jobs: | ||
do-not-merge: | ||
|
||
name: Check | ||
runs-on: ubuntu-22.04 | ||
|
||
# contains(search, item) is not case-sensitive | ||
# Therefore 'Do Not Merge' and 'DO NOT MERGE' will also match | ||
# see https://docs.github.com/en/actions/learn-github-actions/expressions#contains | ||
steps: | ||
- name: fail if label exists | ||
- name: Find Comment | ||
if: ${{ inputs.comment }} && contains(github.event.pull_request.labels.*.name, inputs.label) | ||
uses: peter-evans/[email protected] | ||
id: comment | ||
with: | ||
issue-number: ${{ github.event.pull_request.number }} | ||
body-includes: ⚠️ **The merge is blocked.** | ||
|
||
- name: Comment on PR | ||
if: ${{ inputs.comment }} && contains(github.event.pull_request.labels.*.name, inputs.label) && steps.comment.outputs.comment-id == '' | ||
uses: peter-evans/[email protected] | ||
with: | ||
issue-number: ${{ github.event.pull_request.number }} | ||
body: | | ||
⚠️ **The merge is blocked.** | ||
Remove the label '${{ inputs.label }}' to proceed. | ||
- name: Delete Comment | ||
if: ${{ inputs.comment }} && !contains(github.event.pull_request.labels.*.name, inputs.label) && steps.comment.outputs.comment-id != '' | ||
uses: actions/[email protected] | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
github.rest.issues.deleteComment({ | ||
owner:${{ github.event.repository.owner.login }}, | ||
repo: ${{ github.event.repository.name }}, | ||
comment_id: ${{ steps.comment.outputs.comment-id }} | ||
}) | ||
- name: Fail if label exists to block merge | ||
if: contains(github.event.pull_request.labels.*.name, inputs.label) | ||
run: | | ||
echo "This PR has the label '${{ inputs.label }}'." | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters