From 5dde93663c99adb520e7efc67909d39884262f0b Mon Sep 17 00:00:00 2001 From: Splines Date: Tue, 14 Nov 2023 20:56:37 +0100 Subject: [PATCH] Fetch target branch --- .github/workflows/linter.yml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index b391234d4..e5913ed2b 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -16,8 +16,6 @@ jobs: steps: - name: Checkout sources uses: actions/checkout@v4 - with: - fetch-depth: 2 # to also fetch parent commit for git diff - name: Set up Ruby 3 uses: ruby/setup-ruby@v1 @@ -25,6 +23,17 @@ jobs: ruby-version: 3.1.4 bundler-cache: true + # If this action is not triggered from a PR, we use 'mampf-next' as default + # target branch to compare against. This might not cover all use cases. + # But in the end, one has to open a PR anyways and then the correct target + # branch is identified. + # TODO: rename to 'dev' when 'mampf-next' branch is renamed. + - name: Fetch target branch + run: | + targetBranch=${{ github.base_ref || 'mampf-next' }} + echo "Target branch is: $targetBranch" + git fetch origin $targetBranch --depth=1 + # adapted from https://github.com/actions/checkout/issues/520#issuecomment-1167205721 # and: https://robertfaldo.medium.com/commands-to-run-rubocop-and-specs-you-changed-in-your-branch-e6d2f2e4110b # --diff-filter=d excludes deleted files @@ -32,7 +41,6 @@ jobs: # are found matching the pattern - name: Get changed ruby files (git diff) run: | - targetBranch=${{ github.base_ref || 'mampf-next' }} changedFiles=$(git diff --name-only --diff-filter=d -r $targetBranch | grep '\.rb$' || test $? = 1;) printf "Changed ruby files: \n$changedFiles" echo "CHANGED_FILES=\"$changedFiles\"" >> $GITHUB_ENV