Merge pull request #10442 from hashicorp/d-broken-link-check

Add GitHub action to check for broken markdown links
This commit is contained in:
Wilken Rivera 2021-01-06 16:30:38 -05:00
parent 2e78193cc8
commit ba47ee8efd
3 changed files with 40 additions and 1 deletions

14
.github/workflows/linkchecker.yml vendored Normal file
View File

@ -0,0 +1,14 @@
on: [pull_request]
name: Check Markdown links for modified files
jobs:
markdown-link-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: gaurav-nelson/github-action-markdown-link-check@v1
with:
use-quiet-mode: 'yes'
file-extension: 'mdx'
check-modified-files-only: 'yes'
folder-path: 'website/content'

View File

@ -0,0 +1,14 @@
on:
schedule:
- cron: "45 0 * * *"
name: Check Markdown links on main branch
jobs:
markdown-link-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: gaurav-nelson/github-action-markdown-link-check@v1
with:
use-quiet-mode: 'yes'
file-extension: 'mdx'
folder-path: 'website/content'

View File

@ -20,6 +20,7 @@ This subdirectory contains the entire source for the [Packer Website](https://pa
- [Editing Markdown Content](#editing-markdown-content)
- [Editing Navigation Sidebars](#editing-navigation-sidebars)
- [Changing the Release Version](#changing-the-release-version)
- [Link Validation](#link-validation)
- [Redirects](#redirects)
- [Browser Support](#browser-support)
- [Deployment](#deployment)
@ -148,7 +149,7 @@ $ curl ...
</Tab>
</Tabs>
Contined normal markdown content
Continued normal markdown content
````
The intentionally skipped line is a limitation of the mdx parser which is being actively worked on. All tabs must have a heading, and there is no limit to the number of tabs, though it is recommended to go for a maximum of three or four.
@ -376,6 +377,16 @@ You may customize the parameters in any way you'd like. To remove a prerelease f
<!-- BEGIN: redirects -->
<!-- Generated text, do not edit directly -->
## Link Validation
The Packer GitHub repository is configured to run a [Markdown Link Check](https://github.com/gaurav-nelson/github-action-markdown-link-check#github-action---markdown-link-check-%EF%B8%8F) on a nightly basis to check for potential broken links within the Packer documentation. There is also a GitHub action that will check any modified `.mdx` files on new pull-requests.
The master configuration file for the markdown-link-checker is called `mlc_config.json` and is located under the project's root directory.
The configuration helps with relative links in the documentation that will be valid once deployed, and configures a few ignored URLs which are valid but may not return a valid 200 HTTP response code due to permissions or DDoS protection settings on the domain.
**Potential False Positives**
The link checker will prepend the BASEURL `https://packer.io/` to any relative links found within the documentation, which can be an issue when adding new `/docs` or `/guides` documents as the pages have not been deployed. To help mitigate this issue check the site preview to ensure newly added documentation pages work as expected.
## Redirects
This website structures URLs based on the filesystem layout. This means that if a file is moved, removed, or a folder is re-organized, links will break. If a path change is necessary, it can be mitigated using redirects.