From 06cf4e0f707718176acd72f894816f5ff86ac36c Mon Sep 17 00:00:00 2001 From: Dima Lazerka <58356625+dima-vm@users.noreply.github.com> Date: Tue, 21 Dec 2021 20:27:41 +0200 Subject: [PATCH] Add .github/workflows/check-based-on-master (#1991) --- .github/workflows/check-based-on-master.sh | 12 ++++++++++++ .github/workflows/check-based-on-master.yml | 18 ++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100755 .github/workflows/check-based-on-master.sh create mode 100644 .github/workflows/check-based-on-master.yml diff --git a/.github/workflows/check-based-on-master.sh b/.github/workflows/check-based-on-master.sh new file mode 100755 index 000000000..b95c1334f --- /dev/null +++ b/.github/workflows/check-based-on-master.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +set -x -e +MASTER_ID=$(git rev-parse "origin/master") +CURRENT_ID=$(git rev-parse "HEAD") +BASED_ON_ID=$(git merge-base "$CURRENT_ID" "$MASTER_ID") + +if [[ "$MASTER_ID" != "$BASED_ON_ID" ]] +then + echo "Current branch is based on $BASED_ON_ID, which is not the latest \`master\`: $MASTER_ID. Consider \`git rebase origin/master\`." + exit 1 +fi diff --git a/.github/workflows/check-based-on-master.yml b/.github/workflows/check-based-on-master.yml new file mode 100644 index 000000000..3175bb83b --- /dev/null +++ b/.github/workflows/check-based-on-master.yml @@ -0,0 +1,18 @@ +name: check-based-on-master +on: + pull_request: + push: + branches: [ master ] +jobs: + hook: + name: Check whether this branch is based on master branch + runs-on: ubuntu-latest + steps: + - name: Check out repo @ current branch + uses: actions/checkout@v2 + with: + fetch-depth: 1000 # Hopefully current branch is less than 1000 commits from main + - name: Fetch origin/master + run: "git fetch origin master" + - name: Run check-based-on-master + run: .github/workflows/check-based-on-master.sh