Skip to content

Commit 5a7958e

Browse files
committed
Add an action to check for merge safety
1 parent 45be77b commit 5a7958e

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

.github/workflows/do_not_merge.yaml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: "Check commits can be merged"
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
8+
jobs:
9+
do-not-merge-checker:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Check that there are no commits that should not be merged
14+
uses: gsactions/commit-message-checker@v2
15+
with:
16+
excludeDescription: "true" # optional: this excludes the description body of a pull request
17+
excludeTitle: "true" # optional: this excludes the title of a pull request
18+
checkAllCommitMessages: "true" # optional: this checks all commits associated with a pull request
19+
accessToken: ${{ secrets.GITHUB_TOKEN }} # github access token is only required if checkAllCommitMessages is true
20+
# Check for message indicating that there is a commit that should
21+
# not be merged.
22+
pattern: ^(?!DO NOT MERGE)
23+
flags: "i"
24+
error: |
25+
"This step failed because there is a commit containing the text
26+
'DO NOT MERGE'. Remove this commit from the branch before merging
27+
or change the commit summary."
28+
29+
- uses: actions/checkout@v3
30+
31+
- name: Check requirements.txt for branches
32+
shell: bash
33+
run: |
34+
FILE=requirements.txt
35+
MATCH=tickets/DM-
36+
if grep -q $MATCH $FILE
37+
then
38+
echo "Ticket branches found in $FILE:"
39+
grep -n $MATCH $FILE
40+
exit 1
41+
fi

0 commit comments

Comments
 (0)