Skip to content

Broken Link Check (full) #4

Broken Link Check (full)

Broken Link Check (full) #4

name: Broken Link Check (full)
on:
workflow_dispatch:
schedule:
- cron: "0 0 1 * *"
jobs:
link-checker:
runs-on: ubuntu-latest
if: github.repository == 'hashicorp/web-unified-docs'
steps:
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
- name: Run lychee link checker
id: lychee
uses: lycheeverse/lychee-action@f613c4a64e50d792e0b31ec34bbcbba12263c6a6 # v2.3.0
with:
args: ./content/ -b https://developer.hashicorp.com/ --exclude-all-private --exclude '\.(svg|gif|jpg|png)' --accept 200,408,429 --timeout=60 --max-concurrency 24 --no-progress --verbose
fail: false
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: Close Previous Link Checker Report GitHub Issue with label 'link-checker-report'
uses: actions/stale@5bef64f19d7facfb25b37b414482c7164d639639 # v9.1.0
with:
# Only issues with ALL these labels are checked
only-issue-labels: link-checker-report
# Idle number of days before marking issues stale
# Issues must be marked stale before it can be closed
days-before-issue-stale: 0
# Idle number of days before closing old issues
days-before-issue-close: 0
close-issue-message: "This issue was closed because an updated Link Checker Report has been generated."
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Create GitHub Issue From lychee output file
id: create_issue
if: steps.lychee.outputs.exit_code != 0
uses: peter-evans/create-issue-from-file@e8ef132d6df98ed982188e460ebb3b5d4ef3a9cd # v5.0.1
with:
title: Link Checker Report
content-filepath: ./lychee/out.md
labels: link-checker-report
- name: Report success in GitHub Step Summary
if: steps.lychee.outputs.exit_code == 0
run: |
echo "🎉 No broken links found! 🎉" >> $GITHUB_STEP_SUMMARY
exit 0
- name: Report failure in GitHub Step Summary
if: steps.lychee.outputs.exit_code != 0
run: |
echo "Broken links found, [check the following Github issue for more information.](https://github.com/${{ github.repository }}/issues/${{ steps.create_issue.outputs.issue-number }})" >> $GITHUB_STEP_SUMMARY