Skip to content

Commit f51fb12

Browse files
committed
try more base ref
1 parent c385678 commit f51fb12

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

.github/workflows/beam_PreCommit_Spotless.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,20 @@ jobs:
8888
- name: Setup environment
8989
uses: ./.github/actions/setup-environment-action
9090
- name: Fetch base branch for Spotless ratchet
91-
if: github.event.pull_request.base.ref != ''
91+
env:
92+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9293
run: |
93-
git fetch --no-tags --prune --depth=1 origin ${{ github.event.pull_request.base.ref }}:refs/remotes/origin/${{ github.event.pull_request.base.ref }}
94+
if [ "${{ github.event_name }}" = "pull_request_target" ]; then
95+
BASE_REF="${{ github.event.pull_request.base.ref }}"
96+
elif [ "${{ github.event_name }}" = "issue_comment" ]; then
97+
BASE_REF=$(gh pr view ${{ github.event.issue.number }} --repo ${{ github.repository }} --json baseRefName --jq .baseRefName)
98+
else
99+
BASE_REF="master"
100+
fi
101+
echo "Base ref is $BASE_REF"
102+
if [ -n "$BASE_REF" ]; then
103+
git fetch --no-tags --prune --depth=1 origin ${BASE_REF}:refs/remotes/origin/${BASE_REF}
104+
fi
94105
shell: bash
95106
- name: run Spotless PreCommit script
96107
uses: ./.github/actions/gradle-command-self-hosted-action

0 commit comments

Comments
 (0)