Skip to content

Commit 677790f

Browse files
committed
Add a PR check to check for conflict markers
This check is primarily intended to validate that any merge conflicts in the v2 -> v1 backport PR are fixed before the PR is merged.
1 parent 33c0108 commit 677790f

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Checks for any conflict markers created by git. This check is primarily intended to validate that
2+
# any merge conflicts in the v2 -> v1 backport PR are fixed before the PR is merged.
3+
name: Check for conflicts
4+
5+
on:
6+
pull_request:
7+
branches: [main, v1, v2]
8+
# Run checks on reopened draft PRs to support triggering PR checks on draft PRs that were opened
9+
# by other workflows.
10+
types: [opened, synchronize, reopened, ready_for_review]
11+
12+
jobs:
13+
check-for-conflicts:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v3
17+
18+
- name: Check for conflicts
19+
run: |
20+
# Use `|| true` since grep returns exit code 1 if there are no matches, and we don't want
21+
# this to fail the workflow.
22+
FILES_WITH_CONFLICTS=$(grep --extended-regexp --ignore-case --line-number --recursive \
23+
'^(<<<<<<<|>>>>>>>)' . || true)
24+
if [[ "${FILES_WITH_CONFLICTS}" ]]; then
25+
echo "Fail: Found merge conflict markers in the following files:"
26+
echo ""
27+
echo "${FILES_WITH_CONFLICTS}"
28+
exit 1
29+
else
30+
echo "Success: Found no merge conflict markers."
31+
fi

0 commit comments

Comments
 (0)