@@ -12,9 +12,7 @@ permissions:
1212 contents : read
1313
1414jobs :
15- auto-license-report :
16- permissions :
17- contents : write
15+ generate :
1816 runs-on : ubuntu-latest
1917 steps :
2018 - uses : actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
@@ -33,16 +31,62 @@ jobs:
3331 with :
3432 cache-read-only : true
3533
36- - name : Use CLA approved bot
37- run : .github/scripts/use-cla-approved-bot.sh
38-
3934 - name : Update license report
4035 run : ./gradlew generateLicenseReport --no-build-cache
4136
42- - name : Commit and push if there are changes
37+ - id : create-patch
38+ name : Create patch file
4339 run : |
44- git add licenses
45- if ! git diff --cached --quiet; then
46- git commit -m "Update license report"
47- git push
40+ git diff > patch
41+ if [ -s patch ]; then
42+ echo "exists=true" >> "$GITHUB_OUTPUT"
43+ fi
44+
45+ - name : Upload patch file
46+ if : steps.create-patch.outputs.exists == 'true'
47+ uses : actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
48+ with :
49+ path : patch
50+ name : patch
51+
52+ # separate job is just to isolate the OTELBOT_JAVA_INSTRUMENTATION_PRIVATE_KEY usage a bit
53+ apply :
54+ runs-on : ubuntu-latest
55+ needs : generate
56+ steps :
57+ - name : Download patch
58+ uses : actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
59+ with :
60+ path : ${{ runner.temp }}
61+
62+ - id : check-patch
63+ name : Check patch
64+ working-directory : ${{ runner.temp }}
65+ run : |
66+ if [ -f patch ]; then
67+ echo "exists=true" >> $GITHUB_OUTPUT
4868 fi
69+
70+ - uses : actions/create-github-app-token@67018539274d69449ef7c02e8e71183d1719ab42 # v2.1.4
71+ if : steps.check-patch.outputs.exists == 'true'
72+ id : otelbot-token
73+ with :
74+ app-id : ${{ secrets.OTELBOT_JAVA_INSTRUMENTATION_APP_ID }}
75+ private-key : ${{ secrets.OTELBOT_JAVA_INSTRUMENTATION_PRIVATE_KEY }}
76+
77+ - uses : actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
78+ if : steps.check-patch.outputs.exists == 'true'
79+ with :
80+ token : ${{ steps.otelbot-token.outputs.token }}
81+
82+ - name : Use CLA approved bot
83+ if : steps.check-patch.outputs.exists == 'true'
84+ run : .github/scripts/use-cla-approved-bot.sh
85+
86+ - name : Apply patch and push
87+ if : steps.check-patch.outputs.exists == 'true'
88+ run : |
89+ git apply "${{ runner.temp }}/patch"
90+ git add licenses
91+ git commit -m "Update license report"
92+ git push
0 commit comments