From 34d407fd83204b5e2c5b8819056c0a79d4b9c3ac Mon Sep 17 00:00:00 2001 From: Kaspar Schleiser Date: Wed, 8 Nov 2023 13:23:26 +0100 Subject: [PATCH] ci: workflows: check-commits: fix CI_BASE_BRANCH for merge_groups --- .github/workflows/check-commits.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check-commits.yml b/.github/workflows/check-commits.yml index c4d15bacf70a6..5423e0580c921 100644 --- a/.github/workflows/check-commits.yml +++ b/.github/workflows/check-commits.yml @@ -13,6 +13,13 @@ jobs: matrix: check: [commit-msg, pr_check] steps: + - name: set CI_BASE_BRANCH + run: | + if [ -n "${{ github.base_ref }}" ]; then + echo "CI_BASE_BRANCH=${{ github.base_ref }}" >> $GITHUB_ENV + elif [ -n "${{ github.event.merge_group.base_ref }}" ]; then + echo "CI_BASE_BRANCH=${{ github.event.merge_group.base_ref }}" | sed s.=refs/heads/.=. >> $GITHUB_ENV + fi - uses: actions/checkout@main with: # Use the SHA of the PR branch as-is, not the PR branch merged @@ -22,10 +29,10 @@ jobs: fetch-depth: 0 - name: Fetch base branch run: - git fetch origin '${{ github.base_ref }}:${{ github.base_ref }}' + git fetch origin "${CI_BASE_BRANCH}:${CI_BASE_BRANCH}" - name: Run checks run: | - ./dist/tools/${{ matrix.check }}/check.sh "${{ github.base_ref }}" + ./dist/tools/${{ matrix.check }}/check.sh "${CI_BASE_BRANCH}" check-commits-success: needs: check-commits if: github.event_name != 'merge_group'