File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Check branch status
2+
3+ on :
4+ pull_request :
5+ branches :
6+ - " **"
7+
8+ jobs :
9+ check_branch_history :
10+ name : Check - Linear history
11+ runs-on : ubuntu-latest
12+ steps :
13+ - name : Checkout source code
14+ uses : actions/checkout@v3
15+ with :
16+ ref : ${{ github.event.pull_request.head.sha }} # otherwise, it'd create a merge commit
17+ fetch-depth : " 0"
18+ - name : Check HEAD is rebased on ${{ github.event.pull_request.base.ref }}
19+ run : |
20+ git config --global user.name "$GITHUB_ACTOR"
21+ git config --global user.email "github-actions@github.com"
22+ git fetch origin $GITHUB_BASE_REF
23+ PR_HEAD_SHA=$(git rev-parse HEAD)
24+ git rebase FETCH_HEAD
25+ REBASED_SHA=$(git rev-parse HEAD)
26+ echo "PR HEAD: $PR_HEAD_SHA"
27+ echo "Rebased HEAD: $REBASED_SHA"
28+ git range-diff FETCH_HEAD..$PR_HEAD_SHA FETCH_HEAD..$REBASED_SHA
29+ if [[ "$REBASED_SHA" != "$PR_HEAD_SHA" ]]; then
30+ echo "Not fast forward, aborting!"
31+ echo "Ensure that the PR branch is rebased on $GITHUB_BASE_REF and does not contain merge commits."
32+ exit 1
33+ fi
You can’t perform that action at this time.
0 commit comments