2020-10-24 18:22:35 +08:00
|
|
|
name: Code Formatter
|
|
|
|
|
2020-11-18 09:25:05 +08:00
|
|
|
on: [push, pull_request]
|
2020-10-24 18:22:35 +08:00
|
|
|
jobs:
|
|
|
|
format:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2020-11-02 14:23:33 +08:00
|
|
|
- uses: actions/checkout@master
|
2020-10-24 18:22:35 +08:00
|
|
|
- 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: |
|
2020-10-27 11:16:02 +08:00
|
|
|
git diff
|
2020-10-24 18:22:35 +08:00
|
|
|
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
|
2020-11-02 14:23:33 +08:00
|
|
|
git commit -am "Formatted with Google Java Formatter" || true
|
|
|
|
git push --force origin HEAD:$GITHUB_REF || true
|