Skip to content

Commit 41fd0a3

Browse files
committed
Update spotless automation
1 parent 7ddd49d commit 41fd0a3

File tree

2 files changed

+66
-25
lines changed

2 files changed

+66
-25
lines changed

.github/workflows/auto-update-pull-request.yml

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

48-
- id: get-pr
49-
if: steps.unzip-patch.outputs.exists == 'true'
50-
name: Get PR
51-
env:
52-
PR_BRANCH: |-
53-
${{
54-
(github.event.workflow_run.head_repository.owner.login != github.event.workflow_run.repository.owner.login)
55-
&& format('{0}:{1}', github.event.workflow_run.head_repository.owner.login, github.event.workflow_run.head_branch)
56-
|| github.event.workflow_run.head_branch
57-
}}
58-
GH_TOKEN: ${{ github.token }}
59-
run: |
60-
echo gh pr view "${PR_BRANCH}" --json number --jq .number
61-
number=$(gh pr view "${PR_BRANCH}" --json number --jq .number)
62-
echo $number
63-
echo "number=$number" >> $GITHUB_OUTPUT
64-
65-
- name: Check out PR branch
66-
if: steps.unzip-patch.outputs.exists == 'true'
67-
env:
68-
GH_TOKEN: ${{ github.token }}
69-
run: gh pr checkout ${{ steps.get-pr.outputs.number }}
70-
7150
- name: Use CLA approved github bot
7251
if: steps.unzip-patch.outputs.exists == 'true'
7352
# IMPORTANT do not call the .github/scripts/use-cla-approved-bot.sh
@@ -83,14 +62,34 @@ jobs:
8362
git commit -a -m "./gradlew spotlessApply"
8463
git push
8564
65+
- id: get-pr
66+
if: steps.unzip-patch.outputs.exists == 'true'
67+
name: Get PR
68+
env:
69+
GH_REPO: ${{ github.repository }}
70+
GH_TOKEN: ${{ github.token }}
71+
PR_BRANCH: |-
72+
${{
73+
(github.event.workflow_run.head_repository.owner.login != github.event.workflow_run.repository.owner.login)
74+
&& format('{0}:{1}', github.event.workflow_run.head_repository.owner.login, github.event.workflow_run.head_branch)
75+
|| github.event.workflow_run.head_branch
76+
}}
77+
run: |
78+
number=$(gh pr view "$PR_BRANCH" --json number --jq .number)
79+
echo "number=$number" >> $GITHUB_OUTPUT
80+
8681
- if: steps.unzip-patch.outputs.exists == 'true' && success()
8782
env:
83+
GH_REPO: ${{ github.repository }}
8884
GH_TOKEN: ${{ steps.otelbot-token.outputs.token }}
85+
PR_NUMBER: ${{ steps.get-pr.outputs.number }}
8986
run: |
90-
gh pr comment ${{ steps.get-pr.outputs.number }} --body "🔧 The result from spotlessApply was committed to the PR branch."
87+
gh pr comment $PR_NUMBER --body "🔧 The result from spotlessApply was committed to the PR branch."
9188
9289
- if: steps.unzip-patch.outputs.exists == 'true' && failure()
9390
env:
91+
GH_REPO: ${{ github.repository }}
9492
GH_TOKEN: ${{ steps.otelbot-token.outputs.token }}
93+
PR_NUMBER: ${{ steps.get-pr.outputs.number }}
9594
run: |
96-
gh pr comment ${{ steps.get-pr.outputs.number }} --body "❌ The result from spotlessApply could not be committed to the PR branch, see logs: $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID."
95+
gh pr comment $PR_NUMBER --body "❌ The result from spotlessApply could not be committed to the PR branch, see logs: $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID."
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Create a dummy PR
2+
3+
on:
4+
workflow_dispatch:
5+
6+
permissions:
7+
contents: read
8+
9+
jobs:
10+
create:
11+
permissions:
12+
contents: write
13+
pull-requests: write
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
17+
18+
- name: Need to make some kind of change, and this workflow will no longer be needed after running it the one time, so...
19+
run: git rm .github/workflows/create-dummy-pr.yml
20+
21+
- name: Use CLA approved bot
22+
run: .github/scripts/use-cla-approved-bot.sh
23+
24+
- uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6
25+
id: otelbot-token
26+
with:
27+
app-id: 1295839
28+
private-key: ${{ secrets.OTELBOT_JAVA_INSTRUMENTATION_PRIVATE_KEY }}
29+
30+
- name: Create pull request against the release branch
31+
env:
32+
GH_TOKEN: ${{ steps.otelbot-token.outputs.token }}
33+
run: |
34+
message="A dummy PR to give otelbot-java-instrumentation one merged PR under its belt"
35+
branch="otelbot/dummy-pr"
36+
37+
git checkout -b $branch
38+
git commit -a -m "$message"
39+
git push --set-upstream origin $branch
40+
gh pr create --title "$message" \
41+
--body "$message." \
42+
--base main

0 commit comments

Comments
 (0)