From 5b9118ee4a973597749e66e0ec9111788bd12855 Mon Sep 17 00:00:00 2001 From: Sean McGary Date: Fri, 22 Nov 2024 14:21:25 -0600 Subject: [PATCH] Add github action to check if your branch is up to date Check on PRs only Fix action trigger clean up variables, fetch origin --- .github/workflows/check-merge.yml | 33 +++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 .github/workflows/check-merge.yml diff --git a/.github/workflows/check-merge.yml b/.github/workflows/check-merge.yml new file mode 100644 index 00000000..4e69a55d --- /dev/null +++ b/.github/workflows/check-merge.yml @@ -0,0 +1,33 @@ +name: check-pr-merge +on: + pull_request: + types: + - opened + - synchronize + - reopened + branches: + - master + - "release/*" +jobs: + check-merge: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Check if branch is up to date + env: + BASE_REF: ${{ github.base_ref }} + run: | + baseRef="origin/${BASE_REF}" + echo "Targeting '$baseRef'" + + git fetch origin + + res=$(git --no-pager log HEAD..$baseRef --oneline) + if [[ -z "$res" ]]; then + echo "Branch is up to date with master" + else + echo "Branch is not up to date with master" + echo "Please rebase your branch" + exit 1 + fi