Unverified Commit 20047fcd authored by Delba de Oliveira's avatar Delba de Oliveira Committed by GitHub

Migrate validate links script from next-site and setup GitHub action (#51365)

This PR migrates and adapts the [validate docs links script from `next-site`](https://github.com/vercel/front/pull/23185). This script is triggered by a GitHub action whenever a file in the `/docs` folder is updated. If broken links are found in the docs, the check fails and we post a comment on the PR with a list of broken links.
Co-authored-by: 's avatarMichael Novotny <446260+manovotny@users.noreply.github.com>
parent fc172eea
......@@ -22,6 +22,7 @@ packages/react-dev-overlay/lib/**
.github/actions/next-stats-action/.work
.github/actions/issue-validator/index.mjs
.github/actions/issue-labeler/lib/index.js
.github/actions/validate-docs-links/lib/index.js
packages/next-codemod/transforms/__testfixtures__/**/*
packages/next-codemod/transforms/__tests__/**/*
packages/next-codemod/**/*.js
......
# GitHub Action for Validating Documentation Links
This action ensures that internal links in `.mdx` files in the `/docs/` directory are valid. It runs on every pull request that includes changes to these files.
The action is triggered by the workflow defined in `.github/workflows/validate-docs-links.yml`.
## Usage
This action is written in TypeScript and compiled locally before being pushed to GitHub.
To make changes:
- Edit the `src/index.ts` file.
- Navigate to the script folder `cd .github/actions/validate-docs-links`
- Run `npm install` to install dependencies.
- Run `npm run build` to compile code. This will create an updated `lib/index.js`.
- Commit and push changes to GitHub.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
{
"private": true,
"type": "module",
"exports": "./lib/index.js",
"files": [
"src"
],
"scripts": {
"build": "npm run types && ncc -m -o ./lib build src/index.ts --license licenses.txt",
"types": "tsc"
},
"devDependencies": {
"@types/github-slugger": "^1.3.0",
"@vercel/ncc": "0.34.0"
},
"dependencies": {
"@actions/github": "^5.1.1",
"github-slugger": "1.2.0",
"gray-matter": "4.0.2",
"rehype-raw": "4.0.1",
"remark-parse": "7.0.1",
"remark-rehype": "5.0.0",
"unified": "8.4.1",
"unist-util-visit": "2.0.0"
}
}
This diff is collapsed.
{
"compilerOptions": {
"noEmit": true,
"target": "esnext",
"moduleResolution": "node",
"rootDir": "./src",
"strict": true,
"noImplicitAny": true,
"allowSyntheticDefaultImports": true
}
}
declare module 'remark-rehype'
declare module 'rehype-raw'
name: 'validate-docs-links'
on:
pull_request:
paths:
- 'docs/**.mdx'
jobs:
link-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- name: 'Run link checker'
run: node ./.github/actions/validate-docs-links/lib
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
......@@ -18,6 +18,7 @@ packages/next/src/bundles/webpack/packages/lazy-compilation-*.js
.github/actions/next-stats-action/.work
.github/actions/issue-validator/index.mjs
.github/actions/issue-labeler/lib/index.js
.github/actions/validate-docs-links/lib/index.js
packages/next-swc/crates/**/tests/**/output*
packages/next-swc/crates/core/tests/loader/issue-32553/input.js
......
......@@ -10,4 +10,5 @@ packages/next-codemod/transforms/__tests__/**/*
test/development/basic/hmr/components/parse-error.js
pnpm-lock.yaml
.github/actions/issue-validator/index.mjs
.github/actions/validate-docs-links/lib/index.js
**/convex/_generated/**
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment