Run doc lint only if files changed

This commit is contained in:
Sidharth Vinod
2022-10-03 14:41:52 +08:00
parent 0a547e524e
commit 455c61b2cf

View File

@@ -18,41 +18,37 @@ jobs:
node-version: [16.x] node-version: [16.x]
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
# if: ${{ github.event_name == 'pull_request' }} with:
# with: repository: ${{ github.event.pull_request.head.repo.full_name }}
# fetch-depth: 0 ref: ${{ github.event.pull_request.head.ref }}
# repository: ${{ github.event.pull_request.head.repo.full_name }}
# ref: ${{ github.event.pull_request.head.ref }}
- name: Run changed-files using the fork point of a pull request - name: Check if source docs are changed
id: changed-files-fork-point id: changed-docs
uses: tj-actions/changed-files@v29 uses: tj-actions/changed-files@v29
with: with:
# use_fork_point: 'true'
files: | files: |
packages/mermaid/src/docs/* packages/mermaid/src/docs/*
packages/mermaid/src/docs.mts packages/mermaid/src/docs.mts
- uses: pnpm/action-setup@v2 - uses: pnpm/action-setup@v2
if: steps.changed-files-fork-point.outputs.only_modified == 'true' if: steps.changed-docs.outputs.only_modified == 'true'
# uses version from "packageManager" field in package.json
- name: Setup Node.js ${{ matrix.node-version }} - name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3 uses: actions/setup-node@v3
if: steps.changed-files-fork-point.outputs.only_modified == 'true' if: steps.changed-docs.outputs.only_modified == 'true'
with: with:
cache: pnpm cache: pnpm
node-version: ${{ matrix.node-version }} node-version: ${{ matrix.node-version }}
- name: Install Packages - name: Install Packages
if: steps.changed-files-fork-point.outputs.only_modified == 'true' if: steps.changed-docs.outputs.only_modified == 'true'
run: | run: |
pnpm install --frozen-lockfile pnpm install --frozen-lockfile
env: env:
CYPRESS_CACHE_FOLDER: .cache/Cypress CYPRESS_CACHE_FOLDER: .cache/Cypress
- name: Run step if any file(s) in the docs folder change - name: Run step if any file(s) in the docs folder change
if: steps.changed-files-fork-point.outputs.only_modified == 'true' if: steps.changed-docs.outputs.only_modified == 'true'
run: | run: |
echo "Only files in the src/docs folder has changed." echo "Only files in the src/docs folder has changed."
echo "List all the files that have changed: ${{ steps.changed-files-specific.outputs.all_changed_files }}" echo "List all the files that have changed: ${{ steps.changed-files-specific.outputs.all_changed_files }}"
@@ -60,7 +56,7 @@ jobs:
- name: Commit changes - name: Commit changes
uses: EndBug/add-and-commit@v9 uses: EndBug/add-and-commit@v9
if: steps.changed-files-fork-point.outputs.only_modified == 'true' if: steps.changed-docs.outputs.only_modified == 'true'
with: with:
message: 'Update docs' message: 'Update docs'
add: 'docs/*' add: 'docs/*'