Skip to content

Commit 884dede

Browse files
Merge pull request #3042 from balena-io/vipulgupta2048/check-links
patch: Check links on staging deployments
2 parents 1dddaeb + 91a24f6 commit 884dede

File tree

3 files changed

+51
-27
lines changed

3 files changed

+51
-27
lines changed

.github/workflows/flowzone.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,49 @@ jobs:
2626
with:
2727
cloudflare_website: "balenacloud-docs"
2828
docusaurus_website: false
29+
30+
link-checker:
31+
name: Check links in pull request
32+
runs-on: ubuntu-latest
33+
needs: flowzone
34+
steps:
35+
- name: Checkout code
36+
uses: actions/checkout@v4
37+
38+
# fetch external files && building the docs
39+
- name: Build the docs
40+
uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65
41+
with:
42+
node-version: 18
43+
- run: npm run deploy-docs
44+
45+
- name: Restore lychee cache
46+
id: restore-cache
47+
if: |
48+
github.event_name == 'pull_request' || github.event_name == 'pull_request_target'
49+
uses: actions/cache/restore@v3
50+
with:
51+
path: .lycheecache
52+
key: cache-lychee-${{ github.sha }}
53+
restore-keys: cache-lychee-
54+
55+
# Run link checker on the generated HTML
56+
- name: Link Checker
57+
id: lychee
58+
uses: lycheeverse/lychee-action@2b973e86fc7b1f6b36a93795fe2c9c6ae1118621 # for v1.10.0
59+
env:
60+
DEPLOYMENT_URL: ${{ needs.flowzone.outputs.cloudflare_deployment_url || 'https://docs.balena.io' }}
61+
with:
62+
args: >
63+
-qq
64+
--base ${{ env.DEPLOYMENT_URL }}
65+
--config ./lychee.toml
66+
"build/**/*" "tools/fetch-external.sh"
67+
token: ${{ secrets.GITHUB_TOKEN }}
68+
69+
- name: Save lychee cache
70+
uses: actions/cache/save@v3
71+
if: always()
72+
with:
73+
path: .lycheecache
74+
key: ${{ steps.restore-cache.outputs.cache-primary-key }}

.github/workflows/link-checker.yml

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
11
name: link checker
22

33
on:
4-
repository_dispatch:
54
# Run action manually when needed
65
workflow_dispatch:
76
# Check links once a week on Monday
87
schedule:
98
- cron: "00 00 * * 1"
10-
# Runs on each PR for the master branch
11-
pull_request:
12-
branches:
13-
- "master"
149

1510
jobs:
1611
Checking-Links:
@@ -27,38 +22,21 @@ jobs:
2722
node-version: 18
2823
- run: npm run deploy-docs
2924

30-
- name: Restore lychee cache
31-
id: restore-cache
32-
uses: actions/cache/restore@v3
33-
with:
34-
path: .lycheecache
35-
key: cache-lychee-${{ github.sha }}
36-
restore-keys: cache-lychee-
37-
3825
# Run link checker on the generated HTML
3926
- name: Link Checker
4027
id: lychee
4128
uses: lycheeverse/lychee-action@2b973e86fc7b1f6b36a93795fe2c9c6ae1118621 # for v1.10.0
4229
with:
4330
args: >
31+
--base https://docs.balena.io
4432
--config ./lychee.toml
4533
"build/**/*" "tools/fetch-external.sh"
4634
token: ${{ secrets.GITHUB_TOKEN }}
47-
4835

4936
- name: Create Issue From File
50-
if: |
51-
github.event_name != 'pull_request' &&
52-
env.lychee_exit_code != 0
37+
if: env.lychee_exit_code != 0
5338
uses: peter-evans/create-issue-from-file@v4
5439
with:
5540
title: Link Checker Report
5641
content-filepath: ./lychee/out.md
5742
labels: automated issue
58-
59-
- name: Save lychee cache
60-
uses: actions/cache/save@v3
61-
if: always()
62-
with:
63-
path: .lycheecache
64-
key: ${{ steps.restore-cache.outputs.cache-primary-key }}

lychee.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
# Verbose program output
44
# Accepts log level: "error", "warn", "info", "debug", "trace"
5-
verbose = "info"
5+
verbose = "error"
66

77
# Show progress
8-
progress = true
8+
progress = false
99

1010
# Path to summary output file.
1111
# output = "report.md"
@@ -66,7 +66,7 @@ headers = []
6666
# remap = [ "https://example.com http://example.invalid" ]
6767

6868
# Base URL or website root directory to check relative URLs.
69-
base = "https://docs.balena.io"
69+
# base = "https://docs.balena.io"
7070

7171
# HTTP basic auth support. This will be the username and password passed to the
7272
# authorization HTTP header. See

0 commit comments

Comments
 (0)