Closed Romaixn closed 11 months ago
I'm not sure if this answers your question, but there is a Docker image for the lychee tool: https://github.com/lycheeverse/lychee#docker-usage Maybe that's what you want to integrate into your CI process? If the documentation on how to do it is not sufficient, I'm happy to receive any feedback.
I want to do something like that:
jobs:
linkChecker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 18
- run: npm install -g yarn
- run: yarn install --frozen-lockfile
- run: yarn dev &
- uses: actions/checkout@v3
- name: Link Checker
uses: lycheeverse/lychee-action@v1.8.0
with:
args: --verbose --no-progress http://localhost:3000
fail: true
Is this possible? From my initial tests, it doesn't seem to work, but it might be an error in my CI setup!
Got it.
There might be a timing issue since you're starting the development server and then immediately attempting to run the link checker.
The server may not be ready by the time the link checker starts running, and that could be the issue you're encountering. You might want to introduce a delay to ensure that the server is up and running before running the link checker.
Like this:
jobs:
linkChecker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 18
- run: npm install -g yarn
- run: yarn install --frozen-lockfile
- run: yarn dev &
- name: Wait for server to start
run: sleep 30
- name: Link Checker
uses: lycheeverse/lychee-action@v1.8.0
with:
args: --verbose --no-progress http://localhost:3000
fail: true
Typically you would build the static html with something like yarn build
instead and then just check the public
folder with lychee. Would that be possible for your project?
yarn build
lychee public/
Indeed, it works correctly with a sleep! Thank you very much! And thanks for the advice on the build; it could be more efficient.
Is it possible to verify external URLs? Setting up a Docker in the CI to subsequently check if there are no dead links on the local site, or even verifying an external URL.
Just like with the CLI command:
lychee https://website
(for example)