From 4acfe07656c76d0d3ed6aa5030edb880ee479ead Mon Sep 17 00:00:00 2001 From: Miguel Soriano Date: Mon, 17 Apr 2023 16:35:51 +0200 Subject: [PATCH] feat: add GitHub workflows for Markdown links checking Two GitHub workflows have been added that perform Markdown links checking: * .github/workflows/markdown-link-check-pr.yaml: Executed in each PR. * .github/workflos/markdown-link-check-weekly.yaml: Executed Weekly on Mondays at 07:00 UTC. All the specified md files and directories in the workflows are intentionally checked, independently on whether they have been modified or not. The reason for this is that even if a given .md file has not been modified, its links can become broken. For example, if a PR moves .md files from directories and some other .md files contain relative links referencing the old path of the moved files, then the links become broken even though the file containing the references not being modified. --- .github/workflows/markdown-link-check-pr.yaml | 38 +++++++++++++++++++ .../workflows/markdown-link-check-weekly.yaml | 32 ++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 .github/workflows/markdown-link-check-pr.yaml create mode 100644 .github/workflows/markdown-link-check-weekly.yaml diff --git a/.github/workflows/markdown-link-check-pr.yaml b/.github/workflows/markdown-link-check-pr.yaml new file mode 100644 index 000000000..33b020562 --- /dev/null +++ b/.github/workflows/markdown-link-check-pr.yaml @@ -0,0 +1,38 @@ +name: PR check Markdown links + +# Only run this workflow on PRs +on: + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + +# Disable permissions for all available scopes for the GITHUB_TOKEN +# except for the metadata scope. +permissions: {} + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + pr-markdown-link-check: + # Only run the job on non-draft PRs + if: "github.event.pull_request.draft == false" + name: Check PR Markdown links + runs-on: ubuntu-latest + steps: + - name: Check out code under the $GITHUB_WORKSPACE directory + uses: actions/checkout@v3 + - name: Check markdown links + uses: gaurav-nelson/github-action-markdown-link-check@1.0.15 + with: + use-quiet-mode: 'no' + use-verbose-mode: 'yes' + config-file: './.markdown-link-check/markdown-link-check-config.json' + check-modified-files-only: 'no' + file-extension: '.md' + # Unfortunately there's currently not a way to ignore specific + # directories/paths in the GitHub action so we need to specify + # the desired set of directories/paths that we want to check + # in order to avoid checking undesired directories/paths + folder-path: './docs, ./pkg, ./templates, ./.github, ./cmd, ./internal, ./openapi, ./docker, ./scripts' + file-path: './README.md, ./CONTRIBUTING.md' diff --git a/.github/workflows/markdown-link-check-weekly.yaml b/.github/workflows/markdown-link-check-weekly.yaml new file mode 100644 index 000000000..3638b876f --- /dev/null +++ b/.github/workflows/markdown-link-check-weekly.yaml @@ -0,0 +1,32 @@ +name: Weekly check Markdown links + +# Run this workflow every Monday at 07:00 UTC +on: + schedule: + - cron: "0 7 * * 1" + +# Disable permissions for all available scopes for the GITHUB_TOKEN +# except for the metadata scope. +permissions: {} + +jobs: + weekly-markdown-link-check: + name: Weekly Check Markdown links + runs-on: ubuntu-latest + steps: + - name: Check out code under the $GITHUB_WORKSPACE directory + uses: actions/checkout@v3 + - name: Check markdown links + uses: gaurav-nelson/github-action-markdown-link-check@1.0.15 + with: + use-quiet-mode: 'no' + use-verbose-mode: 'yes' + config-file: './.markdown-link-check/markdown-link-check-config.json' + check-modified-files-only: 'no' + file-extension: '.md' + # Unfortunately there's currently not a way to ignore specific + # directories/paths in the GitHub action so we need to specify + # the desired set of directories/paths that we want to check + # in order to avoid checking undesired directories/paths + folder-path: './docs, ./pkg, ./templates, ./.github, ./cmd, ./internal, ./openapi, ./docker, ./scripts' + file-path: './README.md, ./CONTRIBUTING.md'