-
Notifications
You must be signed in to change notification settings - Fork 1.8k
76 lines (68 loc) · 2.58 KB
/
doc-tests.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
65
66
67
68
69
70
71
72
73
74
75
76
name: Lint (Docs)
run-name: Lint (Docs)
on:
pull_request:
paths:
- 'CHANGELOG.md'
- 'docs/**'
- 'examples/**'
merge_group:
paths:
- 'docs/**'
- 'examples/**'
- 'CHANGELOG.md'
jobs:
doc-tests:
name: Lint (Docs)
if: ${{ !startsWith(github.head_ref, 'dependabot/') }}
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4
with:
repository: "gravitational/docs"
path: "docs"
- name: Prepare docs site configuration
# The environment we use for linting the docs differs from the one we
# use for the live docs site in that we only test a single version of
# the content.
#
# To do this, we replace the three submodules we use for building the
# live docs site with a single submodule, pointing to the
# gravitational/teleport branch we are linting.
#
# The docs engine expects a config.json file at the root of the
# gravitational/docs clone that associates directories with git
# submodules. By default, these directories represent versioned branches
# of gravitational/teleport. We override this in order to build only a
# single version of the docs.
run: |
if [ $GITHUB_EVENT_NAME = "pull_request" ]; then
BRANCH=$GITHUB_HEAD_REF;
elif [ $GITHUB_EVENT_NAME = "merge_group" ]; then
# GitHub populates $GITHUB_REF with:
# refs/heads/gh-readonly-queue/<base branch>/pr-<PR number>-<SHA>
#
# We strip the "refs/heads/" prefix so we can check out the branch.
BRANCH=$(echo $GITHUB_REF | sed -E "s|refs/heads/(.*)|\1|")
else
echo "Unexpected event name: $GITHUB_EVENT_NAME";
exit 1;
fi
cd $GITHUB_WORKSPACE/docs
echo "" > .gitmodules
rm -rf content/*
cd content
git submodule add --force -b $BRANCH -- https://github.com/gravitational/teleport
cd $GITHUB_WORKSPACE/docs
echo "{\"versions\": [{\"name\": \"teleport\", \"branch\": \"$BRANCH\", \"deprecated\": false}]}" > $GITHUB_WORKSPACE/docs/config.json
yarn install
yarn build-node
- name: Check spelling
run: cd $GITHUB_WORKSPACE/docs && yarn spellcheck content/teleport
- name: Lint the docs
run: cd $GITHUB_WORKSPACE/docs && yarn markdown-lint
- name: Test the docs build
run: cd $GITHUB_WORKSPACE/docs && yarn install && yarn build