From a23bac99e82831437ad39fe7c4a1b350110ea136 Mon Sep 17 00:00:00 2001 From: shellhub Date: Sat, 24 Oct 2020 18:22:35 +0800 Subject: [PATCH] support google java style --- .github/workflows/checkstyle.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/workflows/checkstyle.yml diff --git a/.github/workflows/checkstyle.yml b/.github/workflows/checkstyle.yml new file mode 100644 index 000000000..1f9393690 --- /dev/null +++ b/.github/workflows/checkstyle.yml @@ -0,0 +1,24 @@ +name: Code Formatter + +on: [push] + +jobs: + format: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + - name: Set up JDK 12 + uses: actions/setup-java@v1 + with: + java-version: 12 + - 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 + - run: java -jar formatter.jar --replace --set-exit-if-changed $(find . -type f -name "*.java") + - name: Commit Format changes + if: failure() + run: | + git config --global user.name github-actions + git config --global user.email '${GITHUB_ACTOR}@users.noreply.github.com' + git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY + git commit -am "Formatted with Google Java Formatter" + git push --force origin HEAD:$GITHUB_REF \ No newline at end of file