-
Notifications
You must be signed in to change notification settings - Fork 0
61 lines (49 loc) · 1.64 KB
/
validate_and_fix_markdown.yml
File metadata and controls
61 lines (49 loc) · 1.64 KB
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
55
56
57
58
59
60
61
name: Validate and Fix Markdown
on:
pull_request:
branches:
- main
permissions:
contents: write
pull-requests: write
jobs:
validate-and-fix-markdown:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install Markdown linter
run: npm install -g markdownlint-cli
- name: Lint and fix Markdown files
run: markdownlint "**/*.md" --fix --config .github/.markdownlint.json
- name: Validate standard Markdown header
id: validate-header
continue-on-error: true
run: python .github/scripts/validate_markdown_header.py
- name: Configure Git
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
- name: Commit and rebase changes
env:
PR_BRANCH: ${{ github.head_ref || github.ref_name }}
run: |
git add -A
git commit -m "Fix Markdown syntax issues" || echo "No changes to commit"
git pull --rebase origin "$PR_BRANCH" || echo "No rebase needed"
git push origin HEAD:"$PR_BRANCH"
- name: Fail if standard Markdown header validation failed
if: steps.validate-header.outcome == 'failure'
run: |
echo "Standard Markdown header validation failed."
exit 1