GeezerVison is showing github.com — support google java style · gittcommands/Java@a23bac9
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboard +24Lines changed: 24 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +name: Code Formatter |
| 2 | + |
| 3 | +on: [push] |
| 4 | + |
| 5 | +jobs: |
| 6 | + format: |
| 7 | + runs-on: ubuntu-latest |
| 8 | + steps: |
| 9 | + - uses: actions/checkout@v2 |
| 10 | + - uses: actions/setup-python@v2 |
| 11 | + - name: Set up JDK 12 |
| 12 | + uses: actions/setup-java@v1 |
| 13 | + with: |
| 14 | + java-version: 12 |
| 15 | + - run: wget https://github.com/google/google-java-format/releases/download/google-java-format-1.9/google-java-format-1.9-all-deps.jar -O formatter.jar |
| 16 | + - run: java -jar formatter.jar --replace --set-exit-if-changed $(find . -type f -name "*.java") |
| 17 | + - name: Commit Format changes |
| 18 | + if: failure() |
| 19 | + run: | |
| 20 | + git config --global user.name github-actions |
| 21 | + git config --global user.email '${GITHUB_ACTOR}@users.noreply.github.com' |
| 22 | + git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY |
| 23 | + git commit -am "Formatted with Google Java Formatter" |
| 24 | + git push --force origin HEAD:$GITHUB_REF |