-
-
Notifications
You must be signed in to change notification settings - Fork 96
116 lines (99 loc) · 3.65 KB
/
Copy pathdocs.yml
File metadata and controls
116 lines (99 loc) · 3.65 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
name: docs
on:
push:
branches:
- master
pull_request:
permissions:
contents: read # Required to check out repository contents.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
name: Build documentation
permissions:
checks: write # Required by vale-action to publish check annotations.
contents: read # Required to check out repository contents.
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false
- 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@85f9f7f2c5f449ac0ae5b66662961bae3f77ca6a # tag = reviewdog
with:
reporter: github-check
fail_on_error: false
filter_mode: nofilter
files: '["src/en"]'
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
links:
name: Check links
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 0
persist-credentials: false
- name: Find files to check
id: links
shell: bash
env:
EVENT_NAME: ${{ github.event_name }}
PR_BASE_SHA: ${{ github.event.pull_request.base.sha }}
BEFORE_SHA: ${{ github.event.before }}
CURRENT_SHA: ${{ github.sha }}
run: |
if [ "$EVENT_NAME" = "pull_request" ]; then
git diff --name-status --diff-filter=ACMRTD "$PR_BASE_SHA...HEAD" > changed-files.txt
elif [ "$BEFORE_SHA" = "0000000000000000000000000000000000000000" ]; then
git diff-tree --root --no-commit-id --name-status -r "$CURRENT_SHA" > changed-files.txt
else
git diff --name-status --diff-filter=ACMRTD "$BEFORE_SHA..$CURRENT_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@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
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[@]}"