Skip to content

Commit 1334330

Browse files
committed
AUTO
1 parent 811d197 commit 1334330

File tree

1 file changed

+19
-23
lines changed

1 file changed

+19
-23
lines changed

.github/workflows/auto-spotless-apply.yml

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -42,31 +42,10 @@ jobs:
4242
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
4343
if: steps.unzip-patch.outputs.exists == 'true'
4444
with:
45+
repository: "${{ github.event.workflow_run.head_repository }}"
46+
ref: "${{ github.event.workflow_run.head_branch }}"
4547
token: ${{ steps.otelbot-token.outputs.token }}
4648

47-
- id: get-pr
48-
if: steps.unzip-patch.outputs.exists == 'true'
49-
name: Get PR
50-
env:
51-
PR_BRANCH: |-
52-
${{
53-
(github.event.workflow_run.head_repository.owner.login != github.event.workflow_run.repository.owner.login)
54-
&& format('{0}:{1}', github.event.workflow_run.head_repository.owner.login, github.event.workflow_run.head_branch)
55-
|| github.event.workflow_run.head_branch
56-
}}
57-
GH_TOKEN: ${{ github.token }}
58-
run: |
59-
echo gh pr view "${PR_BRANCH}" --json number --jq .number
60-
number=$(gh pr view "${PR_BRANCH}" --json number --jq .number)
61-
echo $number
62-
echo "number=$number" >> $GITHUB_OUTPUT
63-
64-
- name: Check out PR branch
65-
if: steps.unzip-patch.outputs.exists == 'true'
66-
env:
67-
GH_TOKEN: ${{ github.token }}
68-
run: gh pr checkout ${{ steps.get-pr.outputs.number }}
69-
7049
- name: Use CLA approved github bot
7150
if: steps.unzip-patch.outputs.exists == 'true'
7251
# IMPORTANT do not call the .github/scripts/use-cla-approved-bot.sh
@@ -80,8 +59,25 @@ jobs:
8059
run: |
8160
git apply "${{ runner.temp }}/patch"
8261
git commit -a -m "./gradlew spotlessApply"
62+
# explicitly pushing to repo and branch handles edge case where the PR branch name is "<user>/main"
63+
# due to the "main" branch already existing when "gh pr checkout" was run
8364
git push
8465
66+
- id: get-pr
67+
if: steps.unzip-patch.outputs.exists == 'true'
68+
name: Get PR
69+
env:
70+
PR_BRANCH: |-
71+
${{
72+
(github.event.workflow_run.head_repository.owner.login != github.event.workflow_run.repository.owner.login)
73+
&& format('{0}:{1}', github.event.workflow_run.head_repository.owner.login, github.event.workflow_run.head_branch)
74+
|| github.event.workflow_run.head_branch
75+
}}
76+
GH_TOKEN: ${{ github.token }}
77+
run: |
78+
number=$(gh pr view --repo "${{ github.event.workflow_run.repository }}" "${PR_BRANCH}" --json number --jq .number)
79+
echo "number=$number" >> $GITHUB_OUTPUT
80+
8581
- if: steps.unzip-patch.outputs.exists == 'true' && success()
8682
env:
8783
GH_TOKEN: ${{ steps.otelbot-token.outputs.token }}

0 commit comments

Comments
 (0)