File tree Expand file tree Collapse file tree 3 files changed +29
-13
lines changed
Expand file tree Collapse file tree 3 files changed +29
-13
lines changed Original file line number Diff line number Diff line change 1- name : " Check Spotless Formatting "
1+ name : format code
22on :
3- push :
4- branches :
5- - main
6- - release/**
73 pull_request :
84
95jobs :
10- check-formatting :
6+ format-code :
7+ name : Format Code
118 runs-on : ubuntu-latest
129 steps :
13- - name : Checkout 🛎️
10+ - name : Checkout
1411 uses : actions/checkout@v2
12+
1513 - name : set up JDK 11
1614 uses : actions/setup-java@v2
1715 with :
2826 restore-keys : |
2927 ${{ runner.os }}-gradle-
3028
31- - name : Check formatting with Spotless
32- run : make checkFormat
29+ - name : Make format
30+ run : make format
31+
32+ # actions/checkout fetches only a single commit in a detached HEAD state. Therefore
33+ # we need to pass the current branch, otherwise we can't commit the changes.
34+ # GITHUB_HEAD_REF is the name of the head branch. GitHub Actions only sets this for PRs.
35+ - name : Commit Formatted Code
36+ run : ./scripts/commit-formatted-code.sh $GITHUB_HEAD_REF
Original file line number Diff line number Diff line change @@ -150,10 +150,6 @@ spotless {
150150 }
151151}
152152
153- tasks.named(" build" ) {
154- dependsOn(" :spotlessApply" )
155- }
156-
157153gradle.projectsEvaluated {
158154 tasks.create(" aggregateJavadocs" , Javadoc ::class .java) {
159155 setDestinationDir(file(" $buildDir /docs/javadoc" ))
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ set -euo pipefail
3+
4+ GITHUB_BRANCH=" ${1} "
5+
6+ if [[ $( git status) == * " nothing to commit" * ]]; then
7+ echo " Nothing to commit. All code formatted correctly."
8+ else
9+ echo " Formatted some code. Going to push the changes."
10+ git config --global user.name ' Sentry Github Bot'
11+ git config --global user.email ' bot+github-bot@sentry.io'
12+ git fetch
13+ git checkout ${GITHUB_BRANCH}
14+ git commit -am " Format code"
15+ git push --set-upstream origin ${GITHUB_BRANCH}
16+ fi
You can’t perform that action at this time.
0 commit comments