Skip to content

Periodically check docs links #486

Periodically check docs links

Periodically check docs links #486

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
permissions:
issues: write
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod
- name: Links Checker
id: lychee
uses: lycheeverse/lychee-action@7cd0af4c74a61395d455af97419279d86aafaede # v2.0.2
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@24452a72d85239eacf1468b0f1982a9f3fec4c94 # v5.0.0
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.'