-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
76 lines (72 loc) · 2.24 KB
/
md-textlint-check.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
name: Markdown Terminology Lint Check
on:
pull_request:
branches:
- master
paths:
- '**.md'
- '!.github/**'
permissions:
contents: read
pull-requests: write
jobs:
textlint:
runs-on: ubuntu-latest
steps:
- name: Checkout PR
uses: actions/checkout@v4
with:
ref: ${{github.event.pull_request.head.ref}}
repository: ${{github.event.pull_request.head.repo.full_name}}
path: pr
- name: Checkout Base
uses: actions/checkout@v4
with:
repository: OWASP/wstg
path: base
- name: Save PR number
env:
PR_NUMBER: ${{ github.event.number }}
run: echo $PR_NUMBER > pr_number
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install dependencies
run: |
npm install -g textlint
npm install -g textlint-rule-terminology
- name: Changed Files Exporter
id: files
uses: umani/changed-files@138acc60bcaa548e0c194fc69ed36321ee8466d2 # v4.2.0
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
pattern: '^.*\.(md)$'
- name: Run textlint Check
env:
FILES: '${{ steps.files.outputs.files_updated }} ${{ steps.files.outputs.files_created }}'
run: |
touch log.txt
# All markdown files, excluding .github
# Use fix flag so that it goes through all files
for FILE in $FILES; do echo 'pr/'"$FILE" | grep -v \.github && textlint --config base/.github/configs/.textlintrc --fix --rule terminology 'pr/'"$FILE" | tee -a log.txt; done
if grep -q 'Incorrect usage' log.txt ; then exit 1 ; else echo -e \"No terminology issues found.\"; fi
- name: Show Mistakes
if: failure()
run: |
cat log.txt
cat log.txt | grep -v '✔ Fixed' | tr '✔' '✖' >mistakes.txt
- name: Create artifact for comment
if: failure()
run: |
echo "**The following mistakes were identified:**" > artifact.txt
# Copy to generic name for commenting
cat mistakes.txt | tee -a artifact.txt
- name: Upload list of mistakes
if: failure()
uses: actions/upload-artifact@v4
with:
name: artifact
path: |
artifact.txt
pr_number