Skip to content

Commit

Permalink
ci: enforce rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
chintankavathia committed Dec 2, 2024
1 parent ffa9a5a commit 00889a1
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion .github/workflows/test_and_deploy.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,43 @@
name: Build, Test, and Deploy

on: [pull_request]
on:
pull_request:
types:
- opened
- synchronize
- reopened
push:
branches:
- master

jobs:
check-rebase:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Fetch all branches
run: |
git fetch --all
- name: Check for divergence from master
run: |
git fetch origin master
UPSTREAM=${{ github.base_ref }} # Target branch of the pull request (usually master)
CURRENT=$(git rev-parse HEAD) # Latest commit on the PR branch
MERGED=$(git merge-base HEAD origin/$UPSTREAM) # Common ancestor between HEAD and master
if [ "$MERGED" != "$CURRENT" ]; then
echo "This branch is not rebased with the latest master."
exit 1
else
echo "This branch is up-to-date with master."
fi
build:
needs: check-rebase
runs-on: ubuntu-latest

steps:
Expand Down

0 comments on commit 00889a1

Please sign in to comment.