-
Notifications
You must be signed in to change notification settings - Fork 8
64 lines (53 loc) · 2.33 KB
/
validate.yaml
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
name: Validate
on:
pull_request:
branches:
- main
jobs:
validate:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install dependencies
run: pip3 install click colored==1.4.4
- name: Validate front matter for changed files
run: |
git fetch --no-tags origin "${GITHUB_BASE_REF}":"${GITHUB_BASE_REF}"
git diff --name-only "refs/heads/${GITHUB_BASE_REF}" -- . | tee files.txt
cat files.txt | python3 scripts/validate-front-matter/script.py
- name: Print front matter annotations
run: cat ./annotations.json
- name: Send front matter annotations
uses: giantswarm/annotations-action@8028d6604d2db401d4dcd30c21a99fa26e662544
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
title: Front matter problems
input: ./annotations.json
- name: markdownlint
run: |
make RUNNING_IN_CI=true lint || true
# Only fail if the run didn't work for technical reasons
if [ ! -e markdownlint.out ]; then
echo "ERROR: Linting did not write output file with findings"
exit 1
fi
# Otherwise create annotations
cat markdownlint.out \
| jq -nR '[inputs | (. | capture("(?<filename>[^:]+):(?<line>[0-9]+)(:(?<col>[0-9]+))?\\s+(?<description>.+)") | {"file": .filename, "line": (.line | tonumber), "end_line": (.line | tonumber), "title": "markdownlint problem", "message": .description, "annotation_level": "error"})]' \
> markdownlint-annotations.json
- name: Print markdownlint annotations
run: cat ./markdownlint-annotations.json
- name: Send markdownlint annotations
uses: giantswarm/annotations-action@8028d6604d2db401d4dcd30c21a99fa26e662544
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
title: markdownlint problems
input: ./markdownlint-annotations.json
- name: Fail if markdownlint had findings
run: |
# If there are non-empty lines, we had linting findings
if [ "$(awk 1 < markdownlint.out | wc -l | awk '{print $1}')" != 0 ]; then
echo "ERROR: See markdownlint findings (annotated as errors in the PR when you click on 'Files changed')"
exit 1
fi