-
Notifications
You must be signed in to change notification settings - Fork 60.3k
62 lines (54 loc) · 2.79 KB
/
content-lint-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
name: 'Content Lint Markdown'
# **What it does**: Lints our content markdown to ensure the content matches the specified styleguide.
# **Why we have it**: We want some level of consistency to our content markdown files.
# **Who does it impact**: Docs content writers.
on:
pull_request:
merge_group:
permissions:
contents: read
jobs:
lint-content:
if: github.repository == 'github/docs-internal' || github.repository == 'github/docs'
runs-on: ${{ fromJSON('["ubuntu-latest", "ubuntu-20.04-xl"]')[github.repository == 'github/docs-internal'] }}
steps:
- name: Check out repo
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
# Picking this number is a "best guess". If we make it too large,
# the checkout will take potentially unnecessariily long.
# This reduces the chance that tj-actions/changed-files has to
# fetch deeper history. But if it needs to, it will.
fetch-depth: 10
- name: Set up Node and dependencies
uses: ./.github/actions/node-npm-setup
- name: Get changed content/data files
id: changed-files
uses: tj-actions/changed-files@40853de9f8ce2d6cfdc73c1b96f14e22ba44aec4 # v45.0.0
with:
# No need to escape the file names because we make the output of
# tj-actions/changed-files be set as an environment variable. Not
# as a direct input to the line of bash that uses it.
safe_output: false
files: |
content/**
data/**
- name: Print content linter annotations if changed content/data files
if: steps.changed-files.outputs.any_changed == 'true'
env:
# Make it an environment variable so that its value doesn't need to be escaped.
# See https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
CHANGED_FILES: |-
${{ steps.changed-files.outputs.all_changed_files }}
# If there are errors, using `--print-annotations` will make it
# so it does *not* exit non-zero.
# This is so that all warnings and errors are printed.
run: npm run lint-content -- --print-annotations --paths $CHANGED_FILES
- name: Run content linter if changed content/data files
if: steps.changed-files.outputs.any_changed == 'true'
env:
# Make it an environment variable so that its value doesn't need to be escaped.
# See https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
CHANGED_FILES: |-
${{ steps.changed-files.outputs.all_changed_files }}
run: npm run lint-content -- --errors-only --paths $CHANGED_FILES