-
Notifications
You must be signed in to change notification settings - Fork 80
33 lines (31 loc) · 1.15 KB
/
check-mergeable.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
name: Check branch status
on:
pull_request:
branches:
- "**"
jobs:
check_branch_history:
name: Check - Linear history
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }} # otherwise, it'd create a merge commit
fetch-depth: "0"
- name: Check HEAD is rebased on ${{ github.event.pull_request.base.ref }}
run: |
git config --global user.name "$GITHUB_ACTOR"
git config --global user.email "[email protected]"
git fetch origin $GITHUB_BASE_REF
PR_HEAD_SHA=$(git rev-parse HEAD)
git rebase FETCH_HEAD
REBASED_SHA=$(git rev-parse HEAD)
echo "PR HEAD: $PR_HEAD_SHA"
echo "Rebased HEAD: $REBASED_SHA"
git range-diff FETCH_HEAD..$PR_HEAD_SHA FETCH_HEAD..$REBASED_SHA
if [[ "$REBASED_SHA" != "$PR_HEAD_SHA" ]]; then
echo "Not fast forward, aborting!"
echo "Ensure that the PR branch is rebased on $GITHUB_BASE_REF and does not contain merge commits."
exit 1
fi