Skip to content

Commit

Permalink
Check redirects introduced by docs changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ptgott committed Nov 6, 2024
1 parent f494ea6 commit 7ff0438
Showing 1 changed file with 68 additions and 16 deletions.
84 changes: 68 additions & 16 deletions .github/workflows/doc-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,70 @@ jobs:
contents: read

steps:
- name: Checkout
- name: Check out teleport
uses: actions/checkout@v4
with:
repository: 'gravitational/teleport'
path: 'teleport'

- name: Check out docs
uses: actions/checkout@v4
with:
repository: 'gravitational/docs'
path: 'docs'

- name: Generate GitHub Token
id: generate_token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.REVIEWERS_APP_ID }}
private-key: ${{ secrets.REVIEWERS_PRIVATE_KEY }}

- name: Check out shared-workflows
uses: actions/checkout@v4
with:
repository: "gravitational/docs"
path: "docs"
repository: gravitational/shared-workflows
path: .github/shared-workflows
ref: paul.gottschling/2024-11-06-docs-redirs

- name: Install Go
uses: actions/setup-go@v5
with:
go-version: 'stable'

- name: Ensure docs changes include redirects
run: cd .github/shared-workflows/bot && go run main.go -workflow=docpaths -token="${{ steps.generate_token.outputs.token }}" -docs-config-path="${{ github.workspace }}/teleport/docs/config.json" -reviewers="${{ secrets.reviewers }}"

# Cache node_modules. Unlike the example in the actions/cache repo, this
# caches the node_modules directory instead of the yarn cache. This is
# because yarn needs to build fresh packages even when it copies files
# from the yarn cache into node_modules.
# See:
# https://github.com/actions/cache/blob/main/examples.md#node---yarn
- uses: actions/cache@v4
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: '${{ github.workspace }}/docs/node_modules'
key: ${{ runner.os }}-yarn-${{ hashFiles(format('{0}/docs/yarn.lock', github.workspace)) }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install docs site dependencies
working-directory: docs
if: ${{ steps.yarn-cache.outputs.cache-hit != 'true' }}
# Prevent occasional `yarn install` executions that run indefinitely
timeout-minutes: 10
run: yarn install

- 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.
#
# To do this, we delete the three submodules we use for building the
# live docs site and copy a gravitational/teleport clone into the
# content directory.
#
# 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
Expand All @@ -79,21 +128,23 @@ jobs:
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
# Rather than using a submodule, copy the teleport source into the
# content directory.
cp -r $GITHUB_WORKSPACE/teleport $GITHUB_WORKSPACE/docs/content/teleport
cd $GITHUB_WORKSPACE/docs
echo "{\"versions\": [{\"name\": \"teleport\", \"branch\": \"$BRANCH\", \"deprecated\": false}]}" > $GITHUB_WORKSPACE/docs/config.json
yarn install
yarn build-node
jq -nr --arg version $BRANCH '{"versions": [{"name": $version,"branch": $version, "deprecated": false, "latest": true, "current": true }]}' > config.json
cat <<< "$(jq '.scripts."git-update" = "echo Skipping submodule update"' package.json)" > package.json
- 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: Lint docs formatting
working-directory: 'docs'
run: yarn markdown-lint

- name: Test the docs build
run: cd $GITHUB_WORKSPACE/docs && yarn install && yarn build
working-directory: docs
run: yarn build

stylecheck:
name: Lint docs prose style
Expand All @@ -109,7 +160,7 @@ jobs:
repository: "gravitational/teleport"

- name: Run the linter
uses: errata-ai/vale-action@38bf078c328061f59879b347ca344a718a736018 # v2.1.0
uses: errata-ai/vale-action@d89dee975228ae261d22c15adcd03578634d429c # v2.1.1
with:
version: 2.30.0
# Take the comma-separated list of files returned by the "Check for
Expand All @@ -120,4 +171,5 @@ jobs:
# changed files.
filter_mode: added
fail_on_error: true
vale_flags: "--config=docs/.vale.ini"

0 comments on commit 7ff0438

Please sign in to comment.