From ca66bd8e0ab2f56a29d3d5985e3c07800550fb4f Mon Sep 17 00:00:00 2001 From: Peter Wilson Date: Tue, 19 Nov 2024 16:04:43 +0000 Subject: [PATCH] Exit link checker and docs workflow early if no changes to /docs (#394) * Exit link checker and docs workflow early if no changes to /docs * Update name for job --- .github/workflows/build_and_publish_docs.yaml | 19 ++++++++++++++++--- .github/workflows/check_links.yaml | 11 ++++++++++- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build_and_publish_docs.yaml b/.github/workflows/build_and_publish_docs.yaml index dbb002e66..773503438 100644 --- a/.github/workflows/build_and_publish_docs.yaml +++ b/.github/workflows/build_and_publish_docs.yaml @@ -16,7 +16,7 @@ permissions: jobs: build-docs: - name: Build and publish docs + name: Docs - Build and publish runs-on: ubuntu-latest if: ${{ github.event.workflow_run.conclusion == 'success' }} @@ -24,12 +24,22 @@ jobs: - name: Checkout code uses: actions/checkout@v4 + - name: Check for modified paths + uses: dorny/paths-filter@v3 + id: filter + with: + filters: | + changes: + - 'docs/**' + - name: Set up Python 3.11 + if: steps.filter.outputs.changes == 'true' uses: actions/setup-python@v5 with: python-version: "3.11" - name: Set up environment + if: steps.filter.outputs.changes == 'true' id: setup run: | curl -LsSf https://astral.sh/uv/install.sh | sh @@ -38,6 +48,7 @@ jobs: continue-on-error: false - name: Install docs dependencies + if: steps.filter.outputs.changes == 'true' id: install_build_dependencies run: | . .venv/bin/activate @@ -45,22 +56,24 @@ jobs: continue-on-error: false - name: Build documentation + if: steps.filter.outputs.changes == 'true' run: | . .venv/bin/activate cd docs sphinx-build source build/html - name: Set up pages + if: steps.filter.outputs.changes == 'true' uses: actions/configure-pages@v4 - name: Upload artifact - if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} + if: steps.filter.outputs.changes == 'true' && github.event_name == 'push' && github.ref == 'refs/heads/main' uses: actions/upload-pages-artifact@v3 with: path: docs/build/html/ - name: Deploy - if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} + if: steps.filter.outputs.changes == 'true' && github.event_name == 'push' && github.ref == 'refs/heads/main' uses: actions/deploy-pages@v4 with: github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/check_links.yaml b/.github/workflows/check_links.yaml index 800ef3d93..83fb4c4fb 100644 --- a/.github/workflows/check_links.yaml +++ b/.github/workflows/check_links.yaml @@ -3,7 +3,7 @@ name: Link checker on: push: branches: - - '*' + - main pull_request: branches: - "**" @@ -16,7 +16,16 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Check for modified paths + uses: dorny/paths-filter@v3 + id: filter + with: + filters: | + changes: + - 'docs/**' + - name: Link Checker + if: steps.filter.outputs.changes == 'true' id: lychee uses: lycheeverse/lychee-action@v2 with: