-
Notifications
You must be signed in to change notification settings - Fork 80
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
[FEATURE] Add GitHub Action to Check PR Sync with Base Branch #123
Comments
To implement a GitHub Action that checks if a pull request (PR) branch is synchronized with the main branch, I propose the following workflow setup. This action aims to reduce merge conflicts and ensure contributors work with the latest code, improving overall collaboration efficiency. Here are the steps and additional features for this solution: Workflow Setup
name: PR Sync Check with Base Branch
on:
pull_request:
types: [opened, synchronize, reopened]
jobs:
verify-sync:
runs-on: ubuntu-latest
steps:
- name: Checkout PR branch code
uses: actions/checkout@v3
with:
fetch-depth: 0 # Ensures full history for accurate comparison
- name: Fetch base branch for comparison
run: |
BASE_BRANCH="main"
git fetch origin $BASE_BRANCH
- name: Verify PR branch is synced with base branch
id: sync-check
run: |
git diff --exit-code origin/$BASE_BRANCH || exit 1
- name: Notify if PR branch is out-of-sync
if: failure()
run: |
echo "::error ::Your branch is not in sync with the latest changes on the $BASE_BRANCH branch. Please update your branch to avoid merge conflicts."
exit 1 Additional Features
Explanation of Key Steps
Key Benefits
This GitHub Action will help enforce sync checks, maintain code quality, and provide contributors with clear guidelines, ultimately reducing the time spent on merge conflict resolution. @jvedsaqib Yes, I want to work on this issue. Kindly assign it to me with further info if you have some more guidelines/preferences in mind. Thank you :) |
Is this a unique feature?
Is your feature request related to a problem/unavailable functionality? Please describe.
To avoid merge conflicts and ensure that contributors are working with the latest code before opening or updating a Pull Request (PR), we need a GitHub Action that checks whether the contributor has
synced
the latest changes from the base branch i.e. the main branch. If their branch is not up-to-date, the action should block the PR and notify the contributor to sync with the latest changes.Benefits:
Proposed Solution
Contributor can check the following :
Screenshots
No response
Do you want to work on this issue?
No
If "yes" to above, please explain how you would technically implement this (issue will not be assigned if this is skipped)
No response
The text was updated successfully, but these errors were encountered: