Lint (Docs) #81003
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Lint (Docs) | |
run-name: Lint (Docs) | |
on: | |
pull_request: | |
merge_group: | |
jobs: | |
changes: | |
name: Check for relevant changes | |
runs-on: ubuntu-latest | |
permissions: | |
pull-requests: read | |
outputs: | |
changed: ${{ steps.changes.outputs.changed }} | |
changed_files: ${{ steps.changes.outputs.changed_files }} | |
steps: | |
- name: Checkout | |
if: ${{ github.event_name == 'merge_group' }} | |
uses: actions/checkout@v4 | |
- uses: dorny/paths-filter@4512585405083f25c027a35db413c2b3b9006d50 # v2.11.1 | |
id: changes | |
with: | |
base: ${{ github.event.pull_request.base.ref || github.event.merge_group.base_ref }} | |
ref: ${{ github.event.pull_request.head.ref || github.event.merge_group.head_ref }} | |
list-files: csv | |
filters: | | |
changed: | |
- '.github/workflows/doc-tests.yaml' | |
- 'CHANGELOG.md' | |
- 'docs/**' | |
- 'examples/**' | |
doc-tests: | |
name: Lint (Docs) | |
needs: changes | |
if: ${{ !startsWith(github.head_ref, 'dependabot/') && needs.changes.outputs.changed == 'true' }} | |
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 | |
# Add a submodule at docs/content/teleport | |
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 | |
stylecheck: | |
name: Lint docs prose style | |
runs-on: ubuntu-latest | |
needs: changes | |
if: ${{ !startsWith(github.head_ref, 'dependabot/') && needs.changes.outputs.changed == 'true' && github.event_name == 'pull_request' }} | |
permissions: | |
pull-requests: read | |
steps: | |
- name: Check out the teleport repo | |
uses: actions/checkout@v4 | |
with: | |
repository: "gravitational/teleport" | |
- name: Run the linter | |
uses: errata-ai/vale-action@c99f2dfd2aeaedb3d4bb16f385841830b9164d31 # reviewdog | |
with: | |
version: 2.30.0 | |
separator: "," | |
files: ${{ needs.changes.outputs.changed_files }} | |
fail_on_error: true | |