This GitHub action scans a folder (recursively if desired) for a set of code samples, evaluates them to ensure that they compile and run properly. This action is a wrapper around the codechecker-mkdocs python script, and is heavily inspired by:
-
Create a new file in your repository
.github/workflows/action.yml
. -
Copy-paste the following workflow in your
action.yml
file:name: Check code samples on: push jobs: code-sample-check: runs-on: ubuntu-latest steps: - uses: actions/checkout@master - uses: byrnereese/github-action-code-sample-check@v1
Following is a list of some of the repositories which are using GitHub Action - Markdown link check.
(Edit this file and add your name here)
You customize the action by using the following variables:
Variable | Description | Default value |
---|---|---|
excludes |
One or more patterns to identify links that can be excluded or skipped in your tests. | None |
folder-path |
By default the github-action-mkdocs-link-check action checks for all markdown files in your repository, which typically are located in the docs directory for mkdocs projects. Use this option to limit checks to only specific folders. |
docs/ |
syntax-only |
Process code samples for syntax validity only. | false |
languages |
A comma-delimited list of languages to check. | all |
recurse |
Recurse through the entire directory tree below the specified path. | true |
verbose-mode |
Specify yes to show detailed HTTP status for checked links. |
no |
name: Check code samples
on: push
jobs:
code-sample-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: byrnereese/github-action-code-sample-check@v1
with:
use-verbose-mode: 'yes'
folder-path: 'code-samples/'
In addition to checking code samples on every push, or pull request, it is also a good hygine practice to check code samples regularly as well in case errors have been introduced by newer SDKs or software libaries. See Workflow syntax for GitHub Actions - on.schedule for more details.
name: Check Markdown links
on:
push:
branches:
- master
schedule:
# Run everyday at 9:00 AM (See https://pubs.opengroup.org/onlinepubs/9699919799/utilities/crontab.html#tag_20_25_07)
- cron: "0 9 * * *"
jobs:
code-sample-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: byrnereese/github-action-code-sample-check@v1
with:
use-verbose-mode: 'yes'
folder-path: 'code-samples/'
GitHub Action - Markdown link check follows the GitHub recommended versioning strategy.
- To use a specific released version of the action (Releases):
- uses: byrnereese/github-action-code-sample-check@1.0.1
- To use a major version of the action:
- uses: byrnereese/github-action-code-sample-check@v1
- You can also specify a specific commit SHA as an action version:
- uses: byrnereese/github-action-code-sample-check@44a942b2f7ed0dc101d556f281e906fb79f1f478