Skip to content

Commit

Permalink
Check published links
Browse files Browse the repository at this point in the history
  • Loading branch information
recrwplay committed Jan 9, 2024
1 parent b808913 commit e5682ce
Showing 1 changed file with 92 additions and 0 deletions.
92 changes: 92 additions & 0 deletions .github/workflows/reusable-published-links.yml
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?

0 comments on commit e5682ce

Please sign in to comment.