Accept file objects #13
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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@v3 | |
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 |