You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
name: Require Branch to Be Up-to-Date with Production
# Trigger this workflow on pull request events targeting a specific branch.
on:
pull_request:
branches:
- production
- development
- test-protect-main-merge # for testing
workflow_dispatch: # enables manual triggering
jobs:
check-branch:
runs-on: ubuntu-latest
steps:
- name: Checkout pull request branch
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.ref }}
- name: Fetch production branch
run: |
git fetch --unshallow
git fetch origin production
- name: Compare branch with production
run: |
if git merge-base --is-ancestor origin/production HEAD; then
echo "::notice ::Branch is up-to-date with production."
else
echo "::error ::Merge Blocked: Your branch is behind the latest commits on production. Please update your branch with the latest changes from production before attempting to merge."
echo "Merge base: $(git merge-base HEAD origin/production)"