Skip to content

save

save #5

Workflow file for this run

name: AutoFormat
on:
push:
paths:
- '**/*'
branches:
- main
pull_request:
paths:
- '**/*'
branches:
- main
workflow_dispatch:
jobs:
format:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 17
- name: Configure Prettier
run: |
echo '{
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "es5",
"printWidth": 80,
"arrowParens": "always"
}' > .prettierrc
echo '*.min.*
.github/**/*
*-min.*
*.xml' > .prettierignore
- name: Install Prettier with plugins
run: |
npm i -D prettier prettier-plugin-java
- name: Format all files
run: |
npx prettier -w **/*.md
npx prettier -w **/*.java --plugin=prettier-plugin-java
find . -type f -name "*.xml" -exec java -jar tools/android-xml-formatter.jar --indention 2 --attribute-indention 2 {} \;
- name: Clean up unnecessary files
run: |
rm -rf node_modules
rm -f package.json
rm -f package-lock.json
rm -f .prettierrc
rm -f .prettierignore
- name: Commit changes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "actions@github.com"
git add .
git commit -m "auto-format" || echo "No changes to commit"
git push