-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d4d7456
commit ea9a811
Showing
1 changed file
with
25 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,32 @@ | ||
name: Code Formatting | ||
name: Format (prettier) | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
jobs: | ||
format-code: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
push: | ||
branches: | ||
- 'master' | ||
pull_request: | ||
paths: | ||
- '**.css' | ||
- '**.js' | ||
- '**.vue' | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: 14 | ||
jobs: | ||
prettier: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
ref: ${{ github.head_ref }} | ||
|
||
- name: Install dependencies | ||
run: npm install | ||
- name: Install | ||
run: yarn install | ||
env: | ||
CI: true | ||
|
||
- name: Format code using prettier-action | ||
uses: stefanzweifel/prettier-action@v2 | ||
with: | ||
files: . # Specify the files or directories you want to format | ||
prettier: npm # Use 'npm' or 'yarn' depending on your package manager | ||
- name: Run prettier | ||
run: yarn run prettier --write 'src/**/*.{css,js,vue}' | ||
|
||
- name: Commit formatted code | ||
run: | | ||
git config --local user.email "action@github.com" | ||
git config --local user.name "GitHub Action" | ||
git commit -am "Auto-format code" | ||
git push | ||
- uses: stefanzweifel/git-auto-commit-action@v4 | ||
with: | ||
commit_message: Apply prettier changes |