-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
92 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
name: Check links on neo4j.com | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
docs-path: | ||
description: 'The path to the docs to check' | ||
type: string | ||
default: 'https://neo4j.com/docs' | ||
docset: | ||
description: 'The doc set to check' | ||
type: string | ||
default: 'operations-manual' | ||
skipfile: | ||
description: 'The path to the skipfile' | ||
type: string | ||
default: '.docs-tools/link-checker/ignore-links.txt' | ||
retain-artifacts: | ||
description: 'The number of days to retain artifacts' | ||
type: number | ||
default: 7 | ||
workflow_dispatch: | ||
inputs: | ||
docs-path: | ||
description: 'The path to the docs to check' | ||
type: string | ||
default: 'https://neo4j.com/docs' | ||
docset: | ||
description: 'The doc set to check' | ||
type: string | ||
default: 'operations-manual' | ||
skipfile: | ||
description: 'The path to the skipfile' | ||
type: string | ||
default: '.docs-tools/link-checker/ignore-links.txt' | ||
retain-artifacts: | ||
description: 'The number of days to retain artifacts' | ||
type: number | ||
default: 7 | ||
|
||
jobs: | ||
check-links: | ||
runs-on: ubuntu-latest | ||
|
||
env: | ||
DOCS_PATH: ${{ inputs.docs-path }} | ||
DOCSET: ${{ inputs.docset }} | ||
SKIPFILE: ${{ inputs.skipfile }} | ||
|
||
steps: | ||
|
||
- name: Checkout tools repo | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: neo4j/docs-tools | ||
ref: dev | ||
sparse-checkout: | | ||
link-checker | ||
path: .docs-tools | ||
|
||
- name: Use Node.js 16 | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '16' | ||
|
||
- name: Install link checker | ||
run: npm install github:recrwplay/link-checker#v0.2.0 | ||
|
||
- name: Run link checker | ||
run: | | ||
npx link-checker $DOCS_PATH/$DOCSET --skip-file $SKIPFILE -e |& tee link-log.txt | ||
warncount=$(grep -e "[0-9]* warnings" -o link-log.txt | sed 's/ warnings//' ) | ||
if [ $warncount -gt 0 ]; then | ||
echo "::warning:: $warncount warnings" | ||
fi | ||
errorcount=$(grep -e "[0-9]* errors" -o link-log.txt | sed 's/ errors//' ) | ||
if [ $errorcount -gt 0 ]; then | ||
echo "::error:: Errors found: See the output of the Check links step for details" | ||
exit 1 | ||
fi | ||
# upload artifacts | ||
|
||
- name: Save log | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: linklog | ||
path: link-log.txt | ||
|
||
# if errors, raise an issue in the repo and exit 1 to fail the workflow | ||
# tbc... | ||
# create an action. action needs authed token. attach log to issue. extract errors as issue text? |