-
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.
Merge pull request #111 from Staffbase/do-not-merge-action
✨ Add "Do not Merge" Workflow
- Loading branch information
Showing
2 changed files
with
79 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
name: Do Not Merge | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
label: | ||
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 | ||
|
||
steps: | ||
- name: Find Comment | ||
if: inputs.comment | ||
uses: peter-evans/[email protected] | ||
id: comment | ||
with: | ||
issue-number: ${{ github.event.pull_request.number }} | ||
body-includes: ⚠️ **This Pull Request is not ready to be merged.** | ||
|
||
- 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: | | ||
⚠️ **This Pull Request is not ready to be merged.** | ||
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: context.repo.owner, | ||
repo: context.repo.repo, | ||
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 }}'." | ||
exit 1 |
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 |
---|---|---|
|
@@ -231,6 +231,30 @@ jobs: | |
</details> | ||
### Merge Block | ||
<details> | ||
<summary>The action can be used to block the merge if a do not merge label is set.</summary> | ||
```yml | ||
name: Merge Block | ||
|
||
on: | ||
pull_request: | ||
types: [opened, labeled, unlabeled] | ||
|
||
jobs: | ||
block: | ||
uses: Staffbase/gha-workflows/.github/workflows/[email protected] | ||
with: | ||
# optional: name of the label if the PR should not be merged, default: do not merge | ||
label: merge block | ||
# optional: comment when the PR is blocked, default: true | ||
comment: false | ||
``` | ||
</details> | ||
### Release Drafter | ||
<details> | ||
|