-
Notifications
You must be signed in to change notification settings - Fork 6
44 lines (36 loc) · 1 KB
/
auto_format_docs.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
38
39
40
41
42
43
44
name: Format Code
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
format:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: "16"
- name: Install Prettier
run: |
npm install --save-dev prettier
- name: Format YAML and Markdown files
run: |
npx prettier --write "**/*.yml" "**/*.md"
- name: Check for changes
id: check_changes
run: |
git diff --exit-code || echo "Changes detected"
- name: Commit changes
if: steps.check_changes.outputs.exit_code != 0
run: |
git config --local user.name "github-actions"
git config --local user.email "github-actions@github.com"
git add .
git commit -m "Format YAML and Markdown files with Prettier" || echo "No changes to commit"
git push