Skip to content

Periodically check docs links #51

Periodically check docs links

Periodically check docs links #51

name: Periodically check docs links
on:
schedule:
- cron: '0 10 * * 1-5'
workflow_dispatch:
pull_request:
paths:
- '.github/workflows/check-links-cron.yaml'
jobs:
links-checker:
env:
ISSUE_NAME: 'Documentation: broken links automatic report'
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: Links Checker
id: lychee
uses: lycheeverse/lychee-action@ec3ed119d4f44ad2673a7232460dc7dff59d2421 # v1.8.0
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
with:
args: --config .github/lychee.toml --base https://tetragon.io docs/content README.md
# to avoid automated spam, try to find an existing open issue before opening a new one
- name: Search for existing issue number
id: search-issue
run: |
encoded_issue_name=$(echo "$ISSUE_NAME" | sed 's/ /%20/g')
response=$(curl -s -X GET "https://api.github.com/search/issues?q=$encoded_issue_name+repo:cilium/tetragon+state:open+label:automated-issue&type=Issues")
issue_number=$(echo "$response" | jq -r '.items[0].number // empty')
echo "issue_number=$issue_number" >> $GITHUB_OUTPUT
- name: Create or update issue with report
if: env.lychee_exit_code != 0
uses: peter-evans/create-issue-from-file@433e51abf769039ee20ba1293a088ca19d573b7f # v4.0.1
with:
title: ${{ env.ISSUE_NAME }}
content-filepath: ./lychee/out.md
issue-number: ${{ steps.search-issue.outputs.issue_number }}
labels: automated-issue
- name: Close automated issue
if: env.lychee_exit_code == 0 && steps.search-issue.outputs.issue_number != ''
uses: peter-evans/close-issue@276d7966e389d888f011539a86c8920025ea0626 # v3.0.1
with:
issue-number: ${{ steps.search-issue.outputs.issue_number }}
comment: '[Periodic links check](https://github.com/cilium/tetragon/actions/workflows/check-links-cron.yaml) no longer finds broken links, closing issue.'