Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Added Github Actions to check for broken embedded links. #1970

Open
wants to merge 1 commit into
base: osd
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
title: Embedded link(s) inaccessible
labels: bug
---
### Description
Some links in this repository led to a HTTP Status code 404, which means the content is not accessible.
Please check the logs of the workflow below:


{{ env.BODY }}

26 changes: 26 additions & 0 deletions .github/workflows/broken-link-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# This workflow checks if the embedded links are broken in .md files.
# It runs every Thursday at 8AM PST (3PM UTC) and goes through .md files of
# all directories and subdirectories. For any broken link found, it creates
# an issue.

name: Check For Broken Embedded Links

on:
push:
branches:
- main
schedule:
- cron: "0 15 * * 4"

jobs:
check-for-broken-links:
name: Check for broken links
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- id: checking_links
name: checking_links
uses: gaurav-nelson/github-action-markdown-link-check@v1
with:
use-quiet-mode: 'no'
use-verbose-mode: 'yes'
56 changes: 56 additions & 0 deletions .github/workflows/broken-link-issue.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# This workflow runs only when broken-link-check fails. This creates
# an issue using an issue template.

name: Markdown Link Check log parser
on:
workflow_run:
workflows: [
"Check For Broken Embedded Links"
]
types:
- completed
defaults:
run:
shell: pwsh
jobs:
main:
name: Markdown Link Check log parser
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run markdown link check log parser
id: mlc-log-parser
uses: edumserrano/markdown-link-check-log-parser@v1
with:
run-id: '${{ github.event.workflow_run.id }}'
job-name: Check for broken links
step-name: checking_links
only-errors: 'true'
output: 'step-json'
json-filepath: './mlc-json-result.json'
- name: Dump output from previous step
id: data_dump
run: >
$result = '${{ steps.mlc-log-parser.outputs.mlc-result }}' |
ConvertFrom-Json

Write-Output "Total files checked: $($result.TotalFilesChecked)"

Write-Output "Total links checked: $($result.TotalLinksChecked)"

Write-Output "Has errors: $($result.HasErrors)"

$resultAsJsonIndented = ConvertTo-Json -Depth 4 $result

Write-Output $resultAsJsonIndented

- name: Checkout master
uses: actions/checkout@master
- run: >
Write-Output '${{ steps.mlc-log-parser.outputs.mlc-result }}'
- name: Create issue if there are broken links
uses: JasonEtco/create-an-issue@v2.9.1
env:
GITHUB_TOKEN: ${{ github.token }}
BODY: ${{ steps.mlc-log-parser.outputs.mlc-result }}