This repository has been archived by the owner on Oct 26, 2024. It is now read-only.
forked from usnistgov/metaschema
-
Notifications
You must be signed in to change notification settings - Fork 0
72 lines (72 loc) · 2.65 KB
/
workflow-validate-repo-markdown.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
name: Validate Repo Markdown
on:
workflow_call:
inputs:
ignorePattern:
description: 'a pattern provided to grep for files/directories to ignore'
required: false
default: '^website/'
type: string
markdownLinkCheckConfig:
description: 'the path to the markdown link check config file'
required: false
default: '.github/workflows/config/.markdown-link-check/config.json'
type: string
linkcheck_create_issue:
description: 'create new GitHub issue if broken links found'
required: false
default: false
type: boolean
jobs:
validate-repo-markdown:
name: Validate Repo Markdown
runs-on: ubuntu-20.04
permissions:
contents: read
issues: write
steps:
# use this for pulls where checkout is anonymous
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633
with:
submodules: recursive
# Setup runtime environment
# -------------------------
- name: Set up NodeJS
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8
with:
node-version-file: '.github/workflows/config/.nvmrc'
cache: 'npm'
cache-dependency-path: 'package-lock.json'
- name: Setup Dependencies
run: |
# NodeJS
# If you are a developer and need to modify the workflow, be sure to review
# the package.json and package-lock.json to ensure the following deps are
# at least installed (they will be updated by dependabot):
# - ajv-cli
# - ajv-formats
# - markdown-link-check
# - yaml-convert
npm install --loglevel verbose
echo "$PWD/node_modules/.bin/" >> $GITHUB_PATH
# Build Artifacts
# ---------------
- name: Validate repo Markdown content instances
run: |
# this command will filter out any docs Markdown files, which are checked in a different job
git ls-files "*.md" -z | \
grep --null-data -v "${{ inputs.ignorePattern }}" | \
xargs -0 markdown-link-check -c "${{ inputs.markdownLinkCheckConfig }}" | \
tee mlc_report.log
# Exit code of xargs and markdown-link-check, not git or grep or tee pipe elements
exit ${PIPESTATUS[2]}
id: linkchecker
- name: Create issue if bad links detected in repo
if: failure() && inputs.linkcheck_create_issue == true
uses: peter-evans/create-issue-from-file@24452a72d85239eacf1468b0f1982a9f3fec4c94 # v3.0.0
with:
title: Scheduled Check of Markdown Documents Found Bad Hyperlinks
content-filepath: mlc_report.log
labels: |
bug
documentation