Skip to content

Commit

Permalink
build: improve the linkinator action (#212)
Browse files Browse the repository at this point in the history
* build: tune the linkinator workflow

Signed-off-by: Yurii Shynbuiev <[email protected]>

* build: tune the linkinator workflow #2

Signed-off-by: Yurii Shynbuiev <[email protected]>

* build: tune the linkinator workflow #3

Signed-off-by: Yurii Shynbuiev <[email protected]>

* build: tune the linkinator workflow #4

Signed-off-by: Yurii Shynbuiev <[email protected]>

* build: tune the linkinator workflow #5

Signed-off-by: Yurii Shynbuiev <[email protected]>

* build: tune the linkinator workflow - verbosity error

Signed-off-by: Yurii Shynbuiev <[email protected]>

* build: tune up the linkinator workflow - step summary

Signed-off-by: Yurii Shynbuiev <[email protected]>

* build: tune up the linkinator workflow - broken count

Signed-off-by: Yurii Shynbuiev <[email protected]>

* build: tune up the linkinator workflow - add userAgent

Signed-off-by: Yurii Shynbuiev <[email protected]>

* build: tune up the linkinator workflow - add userAgent

Signed-off-by: Yurii Shynbuiev <[email protected]>

* build: tune up the linkinator workflow - skip identity.foundation (403 error)

Signed-off-by: Yurii Shynbuiev <[email protected]>

---------

Signed-off-by: Yurii Shynbuiev <[email protected]>
  • Loading branch information
yshyn-iohk authored Feb 28, 2025
1 parent 78b4061 commit 7a87c8b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 8 deletions.
34 changes: 30 additions & 4 deletions .github/workflows/link-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,45 @@ jobs:
node-version: "18"

- name: Wait for GitHub Pages deployment
if: github.event_name == 'push'
run: sleep 60s # Delay to allow deployment to complete

- name: Get short SHA
run: echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV

- name: Check links on the live site
- name: Check links on the live site to the action output
run: |
echo "Commit SHA: $SHORT_SHA"
npx linkinator https://hyperledger-identus.github.io/docs/ --config .linkinatorrc.json --format text
npx linkinator https://hyperledger-identus.github.io/docs/ --config .linkinatorrc.json > link-check-results.json
npx linkinator https://hyperledger-identus.github.io/docs/ --config .linkinatorrc.json --format text || EXIT_CODE=$?
echo "LINKINATOR_EXIT_CODE=${EXIT_CODE:-0}" >> $GITHUB_ENV
- name: Check links on the live site and safe to a file
if: env.LINKINATOR_EXIT_CODE != 0
run: |
npx linkinator https://hyperledger-identus.github.io/docs/ --config .linkinatorrc.json > link-check-results.json || true
- name: Generate Markdown Table from Linkinator Results
if: env.LINKINATOR_EXIT_CODE != 0
run: |
echo "| URL | Status | Parent Page |" >> link-report.md
echo "|-----|--------|-------------|" >> link-report.md
jq -r '.links[] | select(.state == "BROKEN") | "| \(.url) | \(.status) | \(.parent) |"' link-check-results.json >> link-report.md
BROKEN_COUNT=$(jq '[.links[] | select(.state == "BROKEN")] | length' link-check-results.json)
echo "### 🔗 Broken Links Report( $BROKEN_COUNT found)" >> $GITHUB_STEP_SUMMARY
cat link-report.md >> $GITHUB_STEP_SUMMARY
- name: Upload Linkinator output
if: env.LINKINATOR_EXIT_CODE != 0
uses: actions/upload-artifact@v4
with:
name: linkinator-results-${{ env.SHORT_SHA }}
path: link-check-results.txt
path: link-check-results.json

- name: Fail the build if there are broken links
if: env.LINKINATOR_EXIT_CODE != 0
run: |
echo "Broken links detected. Check the artifact for details."
exit 1
8 changes: 4 additions & 4 deletions .linkinatorrc.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
{
"recurse": true,
"concurrency": 10,
"concurrency": 16,
"format": "JSON",
"verbosity": "info",
"timeout": 30000,
"verbosity": "error",
"skip": [
"https://example.org/*",
"https://example.com/*",
Expand All @@ -12,6 +11,7 @@
"http://issuer-agent.com/*",
"https://didcomm.org/*",
"http://localhost*",
"https://host.docker.internal*"
"https://host.docker.internal*",
"https://identity.foundation/*"
]
}

0 comments on commit 7a87c8b

Please sign in to comment.