Skip to content

Commit f4ff5f4

Browse files
authored
Simplify auto spotless workflow (#1919)
1 parent f597cbe commit f4ff5f4

File tree

1 file changed

+17
-23
lines changed

1 file changed

+17
-23
lines changed

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

Lines changed: 17 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.full_name }}"
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
@@ -82,6 +61,21 @@ jobs:
8261
git commit -a -m "./gradlew spotlessApply"
8362
git push
8463
64+
- id: get-pr
65+
if: steps.unzip-patch.outputs.exists == 'true'
66+
name: Get PR
67+
env:
68+
PR_BRANCH: |-
69+
${{
70+
(github.event.workflow_run.head_repository.owner.login != github.event.workflow_run.repository.owner.login)
71+
&& format('{0}:{1}', github.event.workflow_run.head_repository.owner.login, github.event.workflow_run.head_branch)
72+
|| github.event.workflow_run.head_branch
73+
}}
74+
GH_TOKEN: ${{ github.token }}
75+
run: |
76+
number=$(gh pr view --repo "${{ github.event.workflow_run.repository.full_name }}" "${PR_BRANCH}" --json number --jq .number)
77+
echo "number=$number" >> $GITHUB_OUTPUT
78+
8579
- if: steps.unzip-patch.outputs.exists == 'true' && success()
8680
env:
8781
GH_TOKEN: ${{ steps.otelbot-token.outputs.token }}

0 commit comments

Comments
 (0)