Skip to content

workflows: check only updated docs links in PRs #1045

workflows: check only updated docs links in PRs

workflows: check only updated docs links in PRs #1045

Workflow file for this run

name: Check docs links
on:
pull_request:
paths:
- 'README.md'
- 'docs/content/**.md'
- '.github/workflows/check-links-pr.yaml'
branches:
- 'main'
jobs:
links-checker:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod
- name: Setup Hugo
uses: peaceiris/actions-hugo@16361eb4acea8698b220b76c0d4e84e1fd22c61d # v2.6.0
with:
hugo-version: '0.120.4'
extended: true
- name: Retrieve diff and replace GitHub main links with local branch
shell: bash
run: |
REPO=${{ github.event.pull_request.head.repo.full_name }}
BRANCH=${{ github.event.pull_request.head.ref }}
git diff -U0 origin/${{ github.base_ref }} -- docs/content README.md | grep ^\+[^+] > add.patch
sed -i "s#/cilium/tetragon/tree/main#/$REPO/tree/$BRANCH#g" add.patch
sed -i "s#/cilium/tetragon/blob/main#/$REPO/blob/$BRANCH#g" add.patch
sed -i "s#/cilium/tetragon/main#/$REPO/$BRANCH#g" add.patch
- name: Serve the Hugo website
working-directory: docs
run: hugo server &
- name: Wait for server to be ready
uses: nick-fields/retry@7152eba30c6575329ac0576536151aca5a72780e # v3.0.0
with:
timeout_seconds: 2
max_attempts: 10
retry_wait_seconds: 3
command: |
set -e
curl -s http://localhost:1313 > /dev/null
- name: Links diff checker
id: lychee
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
LYCHEE_VERSION: v0.14.3
run: |
curl -L https://github.com/lycheeverse/lychee/releases/download/$LYCHEE_VERSION/lychee-$LYCHEE_VERSION-x86_64-unknown-linux-gnu.tar.gz | sudo tar -xz -C /usr/local/bin
lychee - --config .github/lychee.toml --base http://localhost:1313 add.patch