From 90da93137b938f1b6d821d44c30f0427ed36f4fd Mon Sep 17 00:00:00 2001 From: Jirka Borovec <6035284+Borda@users.noreply.github.com> Date: Sat, 14 Oct 2023 01:14:33 +0900 Subject: [PATCH] ci: expose base branch & narrow scope for md links (#183) --- .github/workflows/check-md-links.yml | 26 ++++++++++++++++++-------- .github/workflows/ci-use-checks.yaml | 12 +++++++++--- CHANGELOG.md | 6 ++++++ 3 files changed, 33 insertions(+), 11 deletions(-) diff --git a/.github/workflows/check-md-links.yml b/.github/workflows/check-md-links.yml index dbf848e9..d6bd7a8d 100644 --- a/.github/workflows/check-md-links.yml +++ b/.github/workflows/check-md-links.yml @@ -4,6 +4,11 @@ name: Check Markdown links on: workflow_call: inputs: + base-branch: + description: "Default branch name" + required: true + type: string + default: "master" config-file: description: "Config file (JSON) used for markdown link checks" required: false @@ -13,11 +18,14 @@ on: jobs: markdown-link-check: runs-on: ubuntu-20.04 + env: + CONFIG_FILE: ${{ inputs.config-file }} + MODIFIED_ONLY: "no" steps: - uses: actions/checkout@master - name: Create local version of config - if: inputs.config-file == '' + if: ${{ inputs.config-file == '' }} run: | echo '{ "ignorePatterns": [ @@ -34,16 +42,18 @@ jobs: } ] }' > 'markdown.links.config.json' - echo "CONFIG=markdown.links.config.json" >> $GITHUB_ENV + echo "CONFIG_FILE=markdown.links.config.json" >> $GITHUB_ENV cat 'markdown.links.config.json' - - name: Show local version of config - if: inputs.config-file != '' - run: | - echo "CONFIG=${{ inputs.config-file }}" >> $GITHUB_ENV - cat ${{ inputs.config-file }} + - name: Show config + run: cat ${{ env.CONFIG_FILE }} + - name: narrow scope for PR + if: startsWith(github.event_name, 'pull_request') + run: echo "MODIFIED_ONLY=yes" >> $GITHUB_ENV - name: Checking markdown link uses: gaurav-nelson/github-action-markdown-link-check@v1 with: + base-branch: ${{ inputs.base-branch }} use-quiet-mode: "yes" - config-file: ${{ env.CONFIG }} + check-modified-files-only: ${{ env.MODIFIED_ONLY }} + config-file: ${{ env.CONFIG_FILE }} diff --git a/.github/workflows/ci-use-checks.yaml b/.github/workflows/ci-use-checks.yaml index 19a9b02d..66986a4b 100644 --- a/.github/workflows/ci-use-checks.yaml +++ b/.github/workflows/ci-use-checks.yaml @@ -53,7 +53,13 @@ jobs: requirements-file: "requirements/dev-docs.txt" install-tex: true - check-md-links: + check-md-links-default: uses: ./.github/workflows/check-md-links.yml - #with: - # config-file: ".github/markdown.links.config.json" + with: + base-branch: main + + check-md-links-w-config: + uses: ./.github/workflows/check-md-links.yml + with: + base-branch: main + config-file: ".github/markdown.links.config.json" diff --git a/CHANGELOG.md b/CHANGELOG.md index 76f0be06..b62053c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - CI: allow Other targets for building docs ([#179](https://github.com/Lightning-AI/utilities/pull/179)) +- CI: narrow scope for md links check ([#183](https://github.com/Lightning-AI/utilities/pull/183)) + + ### Deprecated - Deprecated `ModuleAvailableCache` in favor of `RequirementCache` ([#147](https://github.com/Lightning-AI/utilities/pull/147)) @@ -45,6 +48,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - CI: resolve latex dependency for docs builds ([181](https://github.com/Lightning-AI/utilities/pull/181)) +- CI: fixed branch for md links check ([#183](https://github.com/Lightning-AI/utilities/pull/183)) + + ## [0.9.0] - 2023-06-29 ### Added