Skip to content

Commit 29b0609

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

File tree

4 files changed

+126
-26
lines changed

4 files changed

+126
-26
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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 Jekyll site for lychee URL checker
24+
uses: actions/upload-artifact@v4
25+
with:
26+
name: build
27+
path: ./_site
28+
if-no-files-found: error
29+
retention-days: 7
30+
- name: Upload artifact for GitHub pages
31+
if: github.event_name != 'pull_request' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
32+
uses: actions/upload-pages-artifact@v4
33+
deploy:
34+
name: Deploy to GitHub pages
35+
if: github.event_name != 'pull_request' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
36+
runs-on: ubuntu-latest
37+
needs: build
38+
steps:
39+
- name: Deploy to GitHub Pages
40+
id: deployment
41+
uses: actions/deploy-pages@v4
42+
environment:
43+
name: github-pages
44+
url: ${{ steps.deployment.outputs.page_url }}
45+
verify_links:
46+
name: Verify website links still work
47+
needs: build
48+
uses: ./.github/workflows/verify-links.yml
49+
permissions:
50+
issues: write # required for peter-evans/create-issue-from-file
51+
with:
52+
create_issue: ${{ github.event_name != 'pull_request' }}

.github/workflows/verify-links.yml

Lines changed: 43 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,42 @@
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

19+
concurrency:
20+
group: ${{ github.workflow }}-${{ github.ref }}
21+
cancel-in-progress: true
22+
1323
jobs:
14-
linkChecker:
24+
link_checker:
1525
runs-on: ubuntu-latest
1626
permissions:
1727
issues: write # required for peter-evans/create-issue-from-file
1828
steps:
19-
- uses: actions/checkout@v4
29+
- uses: actions/download-artifact@v5
30+
with:
31+
name: "build"
32+
path: "prod"
33+
34+
- name: Checkout lychee toml file
35+
uses: actions/checkout@v5
36+
with:
37+
path: repo
38+
sparse-checkout: '.lychee.toml'
39+
sparse-checkout-cone-mode: false
2040

2141
- name: Restore lychee cache
2242
uses: actions/cache@v4
@@ -30,40 +50,37 @@ jobs:
3050
uses: lycheeverse/lychee-action@v2
3151
with:
3252
fail: false
33-
# Exclude all private and local addresses in the check
34-
# Also exclude domains that actively block GitHub to send requests
35-
# Any Cockpit URLs it finds that have variables will be ignored too
3653
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
54+
--root-dir "${{github.workspace}}/prod"
55+
--config "${{github.workspace}}/repo/.lychee.toml"
5156
.
5257
token: ${{ secrets.GITHUB_TOKEN }}
5358

5459
- name: Find the last open report issue
55-
if: steps.lychee.outputs.exit_code != 0
60+
if: |
61+
steps.lychee.outputs.exit_code != 0
62+
&& inputs.create_issue
5663
id: last-issue
5764
uses: micalevisk/last-issue-action@v2
5865
with:
5966
state: open
6067
labels: link-checker
6168

6269
- name: Update or create issue report
63-
if: steps.lychee.outputs.exit_code != 0 && steps.last-issue.outputs.has-found == 'true'
70+
if: |
71+
steps.lychee.outputs.exit_code != 0
72+
&& steps.last-issue.outputs.has-found == 'false'
73+
&& inputs.create_issue
6474
uses: peter-evans/create-issue-from-file@v5
6575
with:
66-
title: Link Checker Report
76+
title: Broken links detected in docs 🔗
6777
content-filepath: ./lychee/out.md
6878
issue-number: ${{ steps.last-issue.outputs.issue-number }}
79+
token: ${{secrets.GITHUB_TOKEN}}
6980
labels: link-checker
81+
82+
- name: Comment Broken Links on PRs
83+
if: github.event_name == 'pull_request'
84+
uses: marocchino/sticky-pull-request-comment@v2
85+
with:
86+
path: lychee/out.md

.lychee.toml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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+
# If we are checking files this will fail as it would match stuff like:
17+
# `file:///blog/authors#name`
18+
'file:///.*#.*'
19+
]
20+
cache = true
21+
cache_exclude_status = "400..=599"
22+
max_cache_age = "1d"
23+
24+
exclude_link_local = true
25+
exclude_loopback = true
26+
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)