Use [linkspector](https://github.com/UmbrellaDocs/linkspector) to check links #897
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright 2024 Zaphiro Technologies | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
# See the License for the specific language governing permissions and | |
# limitations under the License. | |
name: Markdown Lint | |
concurrency: | |
group: ${{ github.ref_name }}-markdown | |
cancel-in-progress: true | |
on: | |
# Trigger the workflow on push or pull request, | |
# but only for the main branch | |
push: | |
branches: | |
- main | |
# Replace pull_request with pull_request_target if you | |
# plan to use this action with forks, see the Limitations section | |
pull_request: | |
branches: | |
- main | |
types: [opened, reopened, ready_for_review, synchronize] | |
workflow_call: | |
inputs: | |
skip-spell-check: | |
required: false | |
default: true | |
type: boolean | |
config-links-path: | |
required: false | |
default: '.github/config/.linkspector.yml' | |
type: string | |
config-lint-path: | |
default: '.github/config/.markdownlint.json' | |
required: false | |
type: string | |
md-lint-globs: | |
required: false | |
type: string | |
default: | | |
**/*.md | |
**/*.MD | |
#.github | |
#vendor | |
#RELEASE_NOTES.md | |
jobs: | |
changes: | |
if: ${{ !github.event.pull_request.draft }} | |
runs-on: ubuntu-latest | |
outputs: | |
files_changed: ${{ steps.filter.outputs.markdown == 'true' || steps.filter.outputs.scripts == 'true' }} | |
markdown_files: ${{ steps.filter.outputs.markdown_files }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 2 # To retrieve the preceding commit. | |
- uses: dorny/paths-filter@v3 | |
id: filter | |
with: | |
list-files: shell | |
filters: | | |
scripts: | |
- '.github/config/.markdownlint.json' | |
- '.github/config/.prettierignore' | |
- '.github/config/.linkspector.yml' | |
- '.gramma.json' | |
- '.grammarignore' | |
- 'grammar-check.sh' | |
- '.github/workflows/markdown.yaml' | |
markdown: | |
- '**/!(*RELEASE_NOTES).(md|MD)' | |
markdown: | |
needs: changes | |
if: ${{ needs.changes.outputs.files_changed == 'true' && !github.event.pull_request.draft }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.REPO_PAT }} | |
ref: ${{github.event.pull_request.head.ref}} | |
repository: ${{github.event.pull_request.head.repo.full_name}} | |
- name: Prettify MD files | |
uses: zaphiro-technologies/prettier_action@main | |
with: | |
prettier_options: --prose-wrap always --write **/*.{md,MD} --ignore-path .github/config/.prettierignore | |
dry: true | |
dry_no_fail: true | |
- name: Lint | |
uses: DavidAnson/markdownlint-cli2-action@v18 | |
with: | |
fix: true | |
config: ${{ inputs.config-lint-path || '.github/config/.markdownlint.json' }} | |
globs: ${{ inputs.md-lint-globs || '**/*.md,**/*.MD,#__tests__/test.md' }} | |
separator: ${{ inputs.md-lint-globs && '' || ',' }} | |
- name: Commit markdown-lint changes | |
run: | | |
git config --global user.name 'Bot' | |
git config --global user.email '[email protected]' | |
git commit -am "Automated markdown-lint fixes [dependabot skip]" || echo "No changes to commit" | |
git push | |
- name: Fix apparmor issue for puppeteer | |
run: echo 0 | sudo tee /proc/sys/kernel/apparmor_restrict_unprivileged_userns | |
- name: Default configuration for link checker | |
run: | | |
FILE=${{ inputs.config-link-path || '.github/config/.linkspector.yml' }} | |
if [ -f $FILE ]; then | |
echo "'$FILE' Exists" | |
else | |
# Write content to the file | |
cat <<EOF > "$FILE" | |
dirs: | |
- . | |
excludedDirs: | |
- vendor | |
useGitIgnore: true | |
aliveStatusCodes: | |
- 200 | |
- 201 | |
- 204 | |
- 206 | |
- 429 | |
ignorePatterns: | |
- pattern: '^http(s?)://localhost' | |
- pattern: '^https://github.com/orgs/zaphiro-technologies/' | |
- pattern: '^https://github.com/zaphiro-technologies/' | |
EOF | |
fi | |
- name: Check links | |
uses: umbrelladocs/action-linkspector@v1 | |
with: | |
filter_mode: nofilter | |
reporter: github-pr-review | |
config_file: ${{ inputs.config-link-path || '.github/config/.linkspector.yml' }} | |
fail_on_error: true | |
markdown-spellchecker: | |
runs-on: ubuntu-latest | |
needs: changes | |
if: ${{ needs.changes.outputs.files_changed == 'true' && !github.event.pull_request.draft && (!inputs.skip-spell-check || inputs.skip-spell-check == '') }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.REPO_PAT }} | |
ref: ${{github.event.pull_request.head.ref}} | |
repository: ${{github.event.pull_request.head.repo.full_name}} | |
- uses: actions/setup-node@v4 | |
- name: Spellcheck | |
shell: bash | |
run: | | |
./grammar-check.sh -f "${{ needs.changes.outputs.markdown_files }}" |