Skip to content

Check for broken links #32

Check for broken links

Check for broken links #32

name: Check for broken links
on:
workflow_dispatch:
schedule:
- cron: '0 17 * * 0' # 9AM PST (5PM UTC) on Sunday mornings
env:
BOT_NAME: svc-docs-eng-opensource-bot
BOT_EMAIL: svc-docs-eng-opensource-bot@newrelic.com
jobs:
check-links:
name: Check for broken links
runs-on: ubuntu-latest
outputs:
broken-links: ${{ steps.run-link-check.outputs.broken-links }}
steps:
- name: Checkout repo
uses: actions/checkout@v3
with:
ref: develop
persist-credentials: false
- name: Setup node.js
uses: actions/setup-node@v3
with:
node-version: 22.4
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Check links
run: |
result=$(scripts/actions/check-links/check-links.sh)
{
echo 'broken-links<<EOF'
echo "$result"
echo EOF
} >> "$GITHUB_OUTPUT"
id: run-link-check
create_issue:
name: Create broken link issue
needs: check-links
if: contains(needs.check-links.outputs.broken-links, '404')
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- name: Create broken link issue
run: |
gh issue create \
--title "Broken link(s) found" \
--body "${{needs.check-links.outputs.broken-links}}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}