forked from KiranAminPanjwani/MedStats
-
Notifications
You must be signed in to change notification settings - Fork 0
37 lines (33 loc) · 1.19 KB
/
format-code.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
name: Format Code
on: push
jobs:
format:
runs-on: ubuntu-20.04
steps:
- name: Pull Repo
uses: actions/checkout@v2
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}
- name: Install Prettier
env:
PRETTIER_VERSION: 2
run: |
sudo npm i -g prettier@$PRETTIER_VERSION
- name: Format
run: |
# don't format if there's no .prettierrc file
if [ ! -f .prettierrc ]; then
echo ".prettierrc not found"
echo "terminating workflow..."
exit 1;
fi
prettier --check . --ignore-unknown --write
- name: Push Back Formatted Code
run: |
# configure git
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
git add .
git commit -m "(CI) format code" || echo "nothing to commit"
git push