From 6421bc996c53a26d298ab70c79e202f55555d468 Mon Sep 17 00:00:00 2001 From: Jayakrishna Konda Date: Tue, 20 Oct 2026 02:57:25 -0400 Subject: [PATCH] Skip build and test jobs for docs-only changes in ci.yml --- .github/workflows/ci.yml | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e3ab24d..ec80d16 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,7 +6,47 @@ on: pull_request: jobs: + # Docs-only changes (Markdown, LICENSE, issue and discussion templates, + # images and pages under docs/) skip the jobs below. They are skipped with a + # job-level `if`, not paths-ignore, so required checks still pass. + changes: + runs-on: ubuntu-latest + outputs: + code: ${{ steps.diff.outputs.code }} + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - id: diff + shell: bash + run: | + if [ "${{ github.event_name }}" = "pull_request" ]; then + base="${{ github.event.pull_request.base.sha }}" + else + base="${{ github.event.before }}" + fi + # No usable base (manual run, new branch, rewritten history): build. + if [ -z "$base" ] || [ "$base" = "0000000000000000000000000000000000000000" ] \ + || ! git cat-file -e "$base^{commit}" 2>/dev/null; then + echo "code=true" >> "$GITHUB_OUTPUT" + exit 0 + fi + changed=$(git diff --name-only "$base" HEAD) + echo "Changed files:" + echo "$changed" + docs='^(.*\.md|LICENSE.*|\.github/(ISSUE_TEMPLATE|DISCUSSION_TEMPLATE)/.*|docs/.*\.(svg|png|jpe?g|gif|webp|ico|html|css))$' + keep='^(README\.md|LICENSE)$' + code_files=$( { echo "$changed" | grep -vE "$docs"; [ -n "$keep" ] && echo "$changed" | grep -E "$keep"; } | grep -c . || true) + if [ "$code_files" -gt 0 ]; then + echo "code=true" >> "$GITHUB_OUTPUT" + else + echo "Docs-only change: skipping the build and test jobs." + echo "code=false" >> "$GITHUB_OUTPUT" + fi + test: + needs: changes + if: needs.changes.outputs.code == 'true' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4