From 792c1a8320fa12519b9d59acffa729917fc4ebe5 Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Wed, 7 Dec 2022 11:19:44 +0530 Subject: [PATCH] chore: Rebuild docs if linting fails --- .github/workflows/lint-docs.yml | 74 --------------------------------- .github/workflows/lint.yml | 16 ++++++- 2 files changed, 15 insertions(+), 75 deletions(-) delete mode 100644 .github/workflows/lint-docs.yml diff --git a/.github/workflows/lint-docs.yml b/.github/workflows/lint-docs.yml deleted file mode 100644 index d9f0ddae0..000000000 --- a/.github/workflows/lint-docs.yml +++ /dev/null @@ -1,74 +0,0 @@ -name: Lint Docs - -on: - pull_request: - types: - - opened - - synchronize - - ready_for_review - -permissions: - contents: write - -jobs: - lint: - runs-on: ubuntu-latest - strategy: - matrix: - node-version: [16.x] - steps: - - uses: actions/checkout@v3 - with: - repository: ${{ github.event.pull_request.head.repo.full_name }} - ref: ${{ github.event.pull_request.head.ref }} - - - name: Get branch name - id: branch-name - uses: tj-actions/branch-names@v5 - - - uses: nrwl/last-successful-commit-action@v1 - id: last_successful_commit_pull_request - with: - branch: ${{ steps.branch-name.outputs.base_ref_branch }} - workflow_id: 'lint-docs.yml' - github_token: ${{ secrets.GITHUB_TOKEN }} - - - name: Check if source docs are changed - id: changed-docs - uses: tj-actions/changed-files@v29 - with: - base_sha: ${{ steps.last_successful_commit_pull_request.outputs.commit_hash }} - files: | - packages/mermaid/src/docs/* - packages/mermaid/src/docs.mts - - - uses: pnpm/action-setup@v2 - if: steps.changed-docs.outputs.only_modified == 'true' - - - name: Setup Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3 - if: steps.changed-docs.outputs.only_modified == 'true' - with: - cache: pnpm - node-version: ${{ matrix.node-version }} - - - name: Install Packages - if: steps.changed-docs.outputs.only_modified == 'true' - run: | - pnpm install --frozen-lockfile - env: - CYPRESS_CACHE_FOLDER: .cache/Cypress - - - name: Run step if any file(s) in the docs folder change - if: steps.changed-docs.outputs.only_modified == 'true' - run: | - 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 }}" - yarn docs:build - - - name: Commit changes - uses: EndBug/add-and-commit@v9 - if: steps.changed-docs.outputs.only_modified == 'true' - with: - message: 'Update docs' - add: 'docs/*' diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 8ba06989d..917a2731c 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -9,7 +9,7 @@ on: - ready_for_review permissions: - contents: read + contents: write jobs: lint: @@ -39,5 +39,19 @@ jobs: run: pnpm run lint - name: Verify Docs + id: verifyDocs working-directory: ./packages/mermaid + continue-on-error: true run: pnpm run docs:verify + + - name: Rebuild Docs + if: ${{ steps.verifyDocs.outcome == 'failure' && github.event_name == 'push' }} + run: | + yarn docs:build + + - name: Commit changes + uses: EndBug/add-and-commit@v9 + if: ${{ steps.verifyDocs.outcome == 'failure' && github.event_name == 'push' }} + with: + message: 'Update docs' + add: 'docs/*'