Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Merge Conflict Check #3138

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
##############################################################################

Check warning on line 1 in .github/workflows/pull-request.yml

View workflow job for this annotation

GitHub Actions / Performs linting, formatting, type-checking, checking for different source and target branch

File ignored by default.
##############################################################################
#
# NOTE!
Expand All @@ -15,6 +15,14 @@
pull_request:
branches:
- '**'
types:
- opened
- reopened
- synchronize
- ready_for_review
pull_request_target:
types:
- synchronize

env:
CODECOV_UNIQUE_NAME: CODECOV_UNIQUE_NAME-${{ github.run_id }}-${{ github.run_number }}
Expand Down Expand Up @@ -449,3 +457,49 @@
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}
GITHUB_REPOSITORY: ${{ github.repository }}

Merge-Conflict-Check:
name: Check for Merge Conflicts
runs-on: ubuntu-latest
if: github.actor != 'dependabot[bot]'
needs: [Code-Quality-Checks]
steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Check Mergeable Status via API
run: |
PR_NUMBER=${{ github.event.pull_request.number }}
max_retries=3
retry_delay=5

for ((i=1; i<=max_retries; i++)); do
echo "Attempt $i of $max_retries"

response=$(curl -s -f -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/pulls/$PR_NUMBER")

if [ $? -ne 0 ]; then
echo "Failed to call GitHub API"
if [ $i -eq $max_retries ]; then
exit 1
fi
sleep $retry_delay
continue
fi

mergeable=$(echo "$response" | jq -r '.mergeable')
if [ "$mergeable" == "true" ]; then
echo "No conflicts detected."
exit 0
elif [ "$mergeable" == "false" ]; then
echo "Merge conflicts detected."
exit 1
else
echo "Mergeable status unknown."
if [ $i -eq $max_retries ]; then
exit 1
fi
sleep $retry_delay
fi
done
Loading