Skip to content

Commit

Permalink
doc,tools: annotate broken links in actions workflow
Browse files Browse the repository at this point in the history
Change format of logged messages when run on GitHub Actions (i.e.
when the `GITHUB_ACTIONS` environment variable is true) so that
broken links are highlighted inline in pull requests.

Signed-off-by: Richard Lau <riclau@uk.ibm.com>
  • Loading branch information
richardlau committed Aug 17, 2020
1 parent c59ac4b commit f1544ec
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tools/doc/checkLinks.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ function checkFile(path) {
const targetURL = new URL(node.url, base);
if (targetURL.protocol === 'file:' && !fs.existsSync(targetURL)) {
const { line, column } = node.position.start;
console.error(`Broken link at ${path}:${line}:${column} (${node.url})`);
console.error((process.env.GITHUB_ACTIONS ?
`::error file=${path},line=${line},col=${column}::` : '') +
`Broken link at ${path}:${line}:${column} (${node.url})`);
process.exitCode = 1;
}
}
Expand Down

0 comments on commit f1544ec

Please sign in to comment.