Skip to content

Commit

Permalink
Simplify PR markdown lint workflow and fix deprecation warnings (#553)
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Morgenstern <[email protected]>
  • Loading branch information
martinmo authored Apr 11, 2024
1 parent f05bdc1 commit 5e9dfd5
Showing 1 changed file with 6 additions and 20 deletions.
26 changes: 6 additions & 20 deletions .github/workflows/pr-markdownlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,26 @@ on:
- main
paths:
- .nvmrc
- package-lock.json
- .github/workflows/pr-markdownlint.yml
- "**/*.md"

jobs:
lint-docs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Get changed files
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BASE_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: |
# Use the GitHub API to get the list of changed files
# documenation: https://docs.github.com/rest/commits/commits#compare-two-commits
DIFF_DOCUMENTS=$(gh api repos/{owner}/{repo}/compare/${{ env.BASE_SHA }}...${{ env.HEAD_SHA }} \
--jq '.files | .[] | select(.status|IN("added", "modified", "renamed", "copied", "changed")) | .filename')
# filter out files that are not markdown
DIFF_DOCUMENTS=$(echo "${DIFF_DOCUMENTS}" | egrep -i "^files/.*\.md$" | xargs)
echo "DIFF_DOCUMENTS=${DIFF_DOCUMENTS}" >> $GITHUB_ENV
- uses: actions/checkout@v4

- name: Setup Node.js environment
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
cache: npm
cache-dependency-path: package-lock.json

cache-dependency-path: package-lock.json

- name: Install all npm packages
run: npm ci

- name: Lint markdown files
run: |
npm run lint:md $DIFF_DOCUMENTS
run: npm run lint:md

0 comments on commit 5e9dfd5

Please sign in to comment.