From 41b0ef0fc9e31a972c1e688345bbd3b203dec022 Mon Sep 17 00:00:00 2001 From: Grace Park Date: Tue, 12 Sep 2023 10:50:21 -0700 Subject: [PATCH] Add content linter to CI (#42192) Co-authored-by: Peter Bengtsson --- .github/workflows/content-lint-markdown.yml | 38 +++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .github/workflows/content-lint-markdown.yml diff --git a/.github/workflows/content-lint-markdown.yml b/.github/workflows/content-lint-markdown.yml new file mode 100644 index 0000000000..0e8a20247a --- /dev/null +++ b/.github/workflows/content-lint-markdown.yml @@ -0,0 +1,38 @@ +name: 'Content Lint Markdown' + +# **What it does**: Lints our content markdown to ensure the content matches the specified styleguide. +# **Why we have it**: We want some level of consistency to our content markdown files. +# **Who does it impact**: Docs content writers. + +on: + pull_request: + +permissions: + contents: read + +jobs: + lint-content: + if: github.repository == 'github/docs-internal' || github.repository == 'github/docs' + runs-on: ${{ fromJSON('["ubuntu-latest", "ubuntu-20.04-xl"]')[github.repository == 'github/docs-internal'] }} + steps: + - name: Check out repo + uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 + with: + # Needed to detect changed files + fetch-depth: 2 + + - name: Set up Node and dependencies + uses: ./.github/actions/node-npm-setup + + - name: Get changed content/data files + id: changed-files + uses: tj-actions/changed-files@246636f5fa148b5ad8e65ca4c57b18af3123e5f6 # v39.0.1 + with: + fetch_depth: 2 + files: | + content/** + data/** + + - name: Run content linter if changed content/data files + if: steps.changed-files.outputs.any_changed == 'true' + run: node src/content-linter/scripts/markdownlint.js --errors-only --paths ${{ steps.changed-files.outputs.all_changed_files }}