Skip to content

Commit b3e0347

Browse files
committed
lychee: Improve CI and add local run command
Signed-off-by: Freya Gustavsson <freya@venefilyn.se>
1 parent 96f41a6 commit b3e0347

File tree

4 files changed

+103
-24
lines changed

4 files changed

+103
-24
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: pages-build-deployment
2+
on:
3+
push:
4+
branches: ["main"]
5+
# TODO: Make better when we have added this to the verify-links workflow
6+
# https://lychee.cli.rs/github_action_recipes/pull-requests/
7+
pull_request:
8+
permissions:
9+
contents: read
10+
pages: write
11+
id-token: write
12+
jobs:
13+
build:
14+
name: Build Jekyll page
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v5
19+
- name: Setup Pages
20+
uses: actions/configure-pages@v5
21+
- name: Build with Jekyll
22+
uses: actions/jekyll-build-pages@v1
23+
- name: Upload artifact
24+
uses: actions/upload-pages-artifact@v4
25+
deploy:
26+
name: Deploy to GitHub pages
27+
if: github.event_name != 'pull_request' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
28+
runs-on: ubuntu-latest
29+
needs: build
30+
steps:
31+
- name: Deploy to GitHub Pages
32+
id: deployment
33+
uses: actions/deploy-pages@v4
34+
environment:
35+
name: github-pages
36+
url: ${{ steps.deployment.outputs.page_url }}
37+
verify_links:
38+
name: Verify website links still work
39+
needs: build
40+
uses: ./.github/workflows/verify-links.yml
41+
permissions:
42+
issues: write # required for peter-evans/create-issue-from-file
43+
with:
44+
create_issue: ${{ github.event_name != 'pull_request' }}

.github/workflows/verify-links.yml

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,35 @@
11
name: Verify links
22

33
on:
4-
push:
5-
branches:
6-
- main
7-
- workflow/verify-links # TODO REMOVE
4+
# push:
5+
# branches:
6+
# - main
7+
# - workflow/verify-links # TODO Remove before merging PR
88
repository_dispatch:
99
workflow_dispatch:
10+
workflow_call:
11+
inputs:
12+
create_issue:
13+
required: false
14+
type: boolean
15+
default: false
1016
schedule:
1117
- cron: "08 08 * * 1"
1218

1319
jobs:
14-
linkChecker:
20+
link_checker:
1521
runs-on: ubuntu-latest
1622
permissions:
1723
issues: write # required for peter-evans/create-issue-from-file
1824
steps:
19-
- uses: actions/checkout@v4
25+
- uses: actions/download-artifact@v5
26+
with:
27+
name: "github-pages"
28+
29+
- name: Checkout lychee toml file
30+
uses: actions/checkout@v5
31+
with:
32+
sparse-checkout: '.lychee.toml'
2033

2134
- name: Restore lychee cache
2235
uses: actions/cache@v4
@@ -29,41 +42,35 @@ jobs:
2942
id: lychee
3043
uses: lycheeverse/lychee-action@v2
3144
with:
32-
fail: false
3345
# Exclude all private and local addresses in the check
3446
# Also exclude domains that actively block GitHub to send requests
3547
# Any Cockpit URLs it finds that have variables will be ignored too
3648
args: |
37-
--max-concurrency 1
38-
--retry-wait-time 60
39-
--base .
40-
--skip-missing
41-
--exclude-all-private
42-
--exclude '^https://linux.die.net'
43-
--exclude 'file:///'
44-
--exclude 'domain.tld'
45-
--exclude '^.*\{\{'
46-
--exclude 'https://bodhi.fedoraproject.org/updates/cockpit-*'
47-
--cache
48-
--cache-exclude-status 400..=599
49-
--max-cache-age 1d
50-
-v
49+
--root-dir "${{github.workspace}}"
50+
--config "${{github.workspace}}/.lychee.toml"
5151
.
5252
token: ${{ secrets.GITHUB_TOKEN }}
53+
continue-on-error: true
5354

5455
- name: Find the last open report issue
55-
if: steps.lychee.outputs.exit_code != 0
56+
if: |
57+
steps.lychee.outputs.exit_code != 0
58+
&& inputs.create_issue
5659
id: last-issue
5760
uses: micalevisk/last-issue-action@v2
5861
with:
5962
state: open
6063
labels: link-checker
6164

6265
- name: Update or create issue report
63-
if: steps.lychee.outputs.exit_code != 0 && steps.last-issue.outputs.has-found == 'true'
66+
if: |
67+
steps.lychee.outputs.exit_code != 0
68+
&& steps.last-issue.outputs.has-found == 'false'
69+
&& inputs.create_issue
6470
uses: peter-evans/create-issue-from-file@v5
6571
with:
66-
title: Link Checker Report
72+
title: Broken links detected in docs 🔗
6773
content-filepath: ./lychee/out.md
6874
issue-number: ${{ steps.last-issue.outputs.issue-number }}
75+
token: ${{secrets.GITHUB_TOKEN}}
6976
labels: link-checker

.lychee.toml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Don't exceed max_concurrency = 1 until this is implemented
2+
# https://github.com/lycheeverse/lychee/issues/989
3+
max_concurrency = 1
4+
retry_wait_time = 60
5+
skip_missing = true
6+
exclude_all_private = true
7+
exclude = [
8+
# '^https://linux.die.net',
9+
# We have this as an example
10+
"domain.tld",
11+
# 'https://bodhi.fedoraproject.org/updates/cockpit-*',
12+
# Not local but used with podman etc.
13+
"0.0.0.0",
14+
# Need to be authenticated with GitHub edits and fails with 404 instead of 403
15+
'^https:\/\/github.com\/cockpit-project\/cockpit\/wiki\/.*\/_edit',
16+
]
17+
cache = true
18+
cache_exclude_status = "400..=599"
19+
max_cache_age = "1d"
20+
21+
exclude_link_local = true
22+
exclude_loopback = true
23+
verbose = "debug"

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
lychee-container:
3+
podman run --init -it -v .:/input:Z,ro lycheeverse/lychee --root-dir "/input/_site" --config "/input/.lychee.toml" /input/_site
4+
5+
.PHONY: lychee-container

0 commit comments

Comments
 (0)