Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
bb38fe5f
Unverified
Commit
bb38fe5f
authored
Jun 23, 2023
by
Delba de Oliveira
Committed by
GitHub
Jun 23, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Docs] Update link validator: use checks, fail on PR from forked repo (#51706)
parent
b7d49e0e
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
16 deletions
+44
-16
index.js
.github/actions/validate-docs-links/lib/index.js
+1
-1
index.ts
.github/actions/validate-docs-links/src/index.ts
+42
-14
validate-docs-links.yml
.github/workflows/validate-docs-links.yml
+1
-1
No files found.
.github/actions/validate-docs-links/lib/index.js
View file @
bb38fe5f
This diff is collapsed.
Click to expand it.
.github/actions/validate-docs-links/src/index.ts
View file @
bb38fe5f
...
...
@@ -325,24 +325,52 @@ const formatTableRow = (link: string, docPath: string) => {
return
`|
${
link
}
| [/
${
docPath
}
](https://github.com/vercel/next.js/blob/
${
sha
}
/
${
docPath
}
) | \n`
}
async
function
createCommit
Status
(
async
function
updateCheck
Status
(
errorsExist
:
boolean
,
commentUrl
?:
string
):
Promise
<
void
>
{
const
state
=
errorsExist
?
'failure'
:
'success'
const
description
=
errorsExist
?
'This PR introduces broken links to the docs. Click details for a list.'
:
'All broken links are now fixed, thank you!'
const
isFork
=
pullRequest
.
head
.
repo
.
fork
const
checkName
=
'Docs Link Validation'
await
octokit
.
rest
.
repos
.
createCommitStatus
({
let
summary
,
text
if
(
errorsExist
)
{
summary
=
'This PR introduces broken links to the docs. Click details for a list.'
text
=
`[See the comment for details](
${
commentUrl
}
)`
}
else
{
summary
=
'No broken links found'
}
const
checkParams
=
{
owner
,
repo
,
sha
,
state
,
description
,
context
:
'Link Validation'
,
target_url
:
commentUrl
,
})
name
:
checkName
,
head_sha
:
sha
,
status
:
'completed'
,
conclusion
:
errorsExist
?
'failure'
:
'success'
,
output
:
{
title
:
checkName
,
summary
:
summary
,
text
:
text
,
},
}
if
(
isFork
)
{
if
(
errorsExist
)
{
setFailed
(
'This PR introduces broken links to the docs. The action could not create a Github check because it is initiated from a forked repo.'
)
}
else
{
console
.
log
(
'Link validation was successful.'
)
}
}
else
{
try
{
await
octokit
.
rest
.
checks
.
create
(
checkParams
)
}
catch
(
error
)
{
setFailed
(
'Failed to create check: '
+
error
)
}
}
}
// Main function that triggers link validation across .mdx files
...
...
@@ -439,9 +467,9 @@ async function validateAllInternalLinks(): Promise<void> {
}
try
{
await
createCommit
Status
(
errorsExist
,
commentUrl
)
await
updateCheck
Status
(
errorsExist
,
commentUrl
)
}
catch
(
error
)
{
setFailed
(
'Failed to create
commit status
: '
+
error
)
setFailed
(
'Failed to create
Github check
: '
+
error
)
}
}
catch
(
error
)
{
setFailed
(
'Error validating internal links: '
+
error
)
...
...
.github/workflows/validate-docs-links.yml
View file @
bb38fe5f
name
:
'
validate-docs-l
inks'
name
:
'
Validate
Doc
L
inks'
on
:
pull_request
:
paths
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment