Skip to content

Commit

Permalink
workflows: only check links added by a PR
Browse files Browse the repository at this point in the history
Previously the PR link checker was checking any link, with this update
it should just try the links added by the PR.

Signed-off-by: Mahe Tardy <[email protected]>
  • Loading branch information
mtardy committed Mar 25, 2024
1 parent 505ce7f commit 49a2e51
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions .github/workflows/check-links-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ on:
jobs:
links-checker:
runs-on: ubuntu-latest
env:
PATCH_FILE: "additions.patch"
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
Expand All @@ -24,22 +26,17 @@ jobs:
hugo-version: '0.120.4'
extended: true

- name: Replace GitHub main links with local branch
- 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 }}
find docs/content/ -type f -name "*.md" -exec sed -i "s#/cilium/tetragon/tree/main#/$REPO/tree/$BRANCH#g" {} \;
sed -i "s#/cilium/tetragon/tree/main#/$REPO/tree/$BRANCH#g" README.md
git diff -U0 origin/${{ github.base_ref }} -- docs/content README.md | grep ^\+[^+] > $PATCH_FILE
find docs/content/ -type f -name "*.md" -exec sed -i "s#/cilium/tetragon/blob/main#/$REPO/blob/$BRANCH#g" {} \;
sed -i "s#/cilium/tetragon/blob/main#/$REPO/blob/$BRANCH#g" README.md
find docs/content/ -type f -name "*.md" -exec sed -i "s#/cilium/tetragon/main#/$REPO/$BRANCH#g" {} \;
sed -i "s#/cilium/tetragon/main#/$REPO/$BRANCH#g" README.md
git diff -U0
sed -i "s#/cilium/tetragon/tree/main#/$REPO/tree/$BRANCH#g" $PATCH_FILE
sed -i "s#/cilium/tetragon/blob/main#/$REPO/blob/$BRANCH#g" $PATCH_FILE
sed -i "s#/cilium/tetragon/main#/$REPO/$BRANCH#g" $PATCH_FILE
- name: Serve the Hugo website
working-directory: docs
Expand All @@ -61,5 +58,5 @@ jobs:
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
with:
args: --config .github/lychee.toml --base http://localhost:1313 docs/content README.md
args: --config .github/lychee.toml --base http://localhost:1313 $PATCH_FILE
fail: true

0 comments on commit 49a2e51

Please sign in to comment.