-
Notifications
You must be signed in to change notification settings - Fork 120
54 lines (45 loc) · 1.27 KB
/
format-markdown.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
45
46
47
48
49
50
51
52
53
54
name: Format Markdown
on:
push:
branches:
- '**'
paths:
- 'content/**/*.md'
jobs:
format-markdown:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 2
token: ${{ secrets.ACCESS_TOKEN }}
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: 18
- name: Install Prettier
run: npm install prettier
- name: Run Prettier
run: npx prettier --write "content/**/*.md" --ignore-path .prettierignore
- name: Commit changes
run: |
git config user.name "GitHub Action"
git config user.email "[email protected]"
export HUSKY=0
git add -A
# Check for meaningful changes before committing
if [ -n "$(git status --porcelain)" ]; then
# Commit only modified markdown files, not all changes
git commit -m "chore: format content markdown files with Prettier"
echo "Changes committed"
else
echo "No significant changes to commit"
exit 0
fi
- name: Pull latest changes
run: git pull --rebase
- name: Push changes
run: git push
env:
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}