-
-
Notifications
You must be signed in to change notification settings - Fork 93
99 lines (84 loc) · 2.92 KB
/
docs.yml
File metadata and controls
99 lines (84 loc) · 2.92 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
name: docs
on:
push:
branches:
- master
pull_request:
permissions:
contents: read
checks: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Fetch styles
run: |
sudo apt install wget unzip
wget https://github.com/errata-ai/Microsoft/releases/latest/download/Microsoft.zip
unzip Microsoft.zip -d .github/styles
- name: Check
uses: errata-ai/vale-action@reviewdog
with:
reporter: github-check
fail_on_error: false
filter_mode: nofilter
files: '["src/en"]'
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
links:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Find files to check
id: links
shell: bash
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
git diff --name-status --diff-filter=ACMRTD "${{ github.event.pull_request.base.sha }}...HEAD" > changed-files.txt
elif [ "${{ github.event.before }}" = "0000000000000000000000000000000000000000" ]; then
git diff-tree --root --no-commit-id --name-status -r "${{ github.sha }}" > changed-files.txt
else
git diff --name-status --diff-filter=ACMRTD "${{ github.event.before }}..${{ github.sha }}" > changed-files.txt
fi
check_all=false
if awk '
/^R/ && ($2 ~ /^src\/public\// || $3 ~ /^src\/public\// || $2 ~ /^src\/.*\.md$/) { found = 1 }
/^D/ && ($2 ~ /^src\/public\// || $2 ~ /^src\/.*\.md$/) { found = 1 }
!/^R/ && !/^D/ && $2 ~ /^src\/public\// { found = 1 }
END { exit found ? 0 : 1 }
' changed-files.txt; then
check_all=true
fi
if [ "$check_all" = true ]; then
find src -name '*.md' | sort > files-to-check.txt
else
awk '
!/^D/ && /^R/ && $3 ~ /^src\/.*\.md$/ { print $3 }
!/^D/ && !/^R/ && $2 ~ /^src\/.*\.md$/ { print $2 }
' changed-files.txt | sort -u > files-to-check.txt
fi
cat files-to-check.txt
echo "count=$(wc -l < files-to-check.txt | tr -d ' ')" >> "$GITHUB_OUTPUT"
- name: No links to check
if: steps.links.outputs.count == '0'
run: echo "No Markdown files need link checking."
- name: Setup Node.js
if: steps.links.outputs.count != '0'
uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- name: Install dependencies
if: steps.links.outputs.count != '0'
run: npm ci
- name: Check links
if: steps.links.outputs.count != '0'
shell: bash
run: |
mapfile -t files < files-to-check.txt
npm run check-links -- "${files[@]}"