Skip to content

Commit

Permalink
added github workflow for auto-formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
SwanX1 committed Dec 28, 2024
1 parent e0a8959 commit 588af43
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Auto-format

concurrency: production

on: [push]

jobs:
format:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Install Prettier
run: npm install prettier prettier-plugin-java

- name: Run Prettier
run: npx prettier --write "**/*.java"

- name: Create commit and push
run: |
git add src --verbose
if [ ! -z "$(git diff --exit-code --staged)" ]; then
git config user.name github-actions
git config user.email [email protected]
git commit --verbose -m "
chore: auto-format
This is an automated commit. It was made by a GitHub workflow.
Action: https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID
"
git push --verbose
else
echo "No changes to commit"
exit 0
fi
11 changes: 11 additions & 0 deletions .prettierrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Prettier configuration
plugins:
- prettier-plugin-java
overrides:
- files:
- "*.java"
options:
printWidth: 140
tabWidth: 2
useTabs: false
trailingComma: "none"

0 comments on commit 588af43

Please sign in to comment.