Skip to content

Commit 98927f1

Browse files
reakaleekclaude
andauthored
docs-deploy: Skip pipeline on default-branch pushes without docs changes (#99)
* docs-deploy: Skip pipeline on default-branch pushes without docs changes Pass effective_any_modified from docs-build's check job to docs-deploy via artifact. On push events, docs-deploy reads the artifact instead of hardcoding has-changes=true, so the build/deploy/link-index pipeline is skipped when no docs-relevant files changed. Version branches keep current behavior (always run) via the existing use-release-branches override in docs-build. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Narrow use-release-branches override to first push (branch creation) The override previously forced effective_any_modified=true on every push to a version branch. Now it only triggers when github.event.created is true (first push), so subsequent pushes to version branches respect actual docs-change detection like the default branch. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent e53c90b commit 98927f1

2 files changed

Lines changed: 49 additions & 9 deletions

File tree

.github/workflows/docs-build.yml

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ on:
3939
required: false
4040
use-release-branches:
4141
description: >
42-
When true, push events to semver release branches (e.g. 9.4) run the docs build even when no docs/** files
43-
changed, so links.json can be produced for the link index. main keeps skip-when-no-docs-diff behavior.
42+
When true, the first push to a new semver release branch (e.g. 9.4) runs the docs build even when no
43+
docs/** files changed, so links.json can be produced for the link index. Subsequent pushes to the same
44+
branch only build when docs files actually change.
4445
type: boolean
4546
default: false
4647
required: false
@@ -191,9 +192,10 @@ jobs:
191192
core.setOutput('deleted_files', deleted.join(' '));
192193
core.setOutput('renamed_files', renamed.join(' '));
193194
194-
# Why: On a release line (e.g. 9.4), months of pushes may touch only code or deps—never docs/. We still need a
195-
# full docs build sometimes so links.json exists for the shared link index. Opt-in repos enable that with
196-
# use-release-branches; Vale lint stays tied to real doc edits (any_modified), not this override.
195+
# Why: When a release branch (e.g. 9.4) is first created, it may share the same commit as the default
196+
# branch, so changed-files reports no diff. We still need a full docs build on that first push so
197+
# links.json is produced for the link index. Subsequent pushes only build when docs files actually change.
198+
# Vale lint stays tied to real doc edits (any_modified), not this override.
197199
- name: Effective any_modified (release-branch opt-in)
198200
id: effective-any-modified
199201
if: always()
@@ -203,21 +205,36 @@ jobs:
203205
EVENT_NAME: ${{ github.event_name }}
204206
REF_NAME: ${{ github.ref_name }}
205207
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
208+
CREATED: ${{ github.event.created }}
206209
run: |
207210
# Empty ANY_MODIFIED means "we did not run changed-files" (e.g. workflow_dispatch), not "no docs changed."
208211
# We only want to skip the docs build when changed-files explicitly reports no matching paths (false).
209212
# Treating empty as true keeps that contract: no diff result => do not infer skip; explicit false => skip
210-
# unless use-release-branches forces a release-line build below.
213+
# unless use-release-branches forces a build on new release branches below.
211214
effective="${ANY_MODIFIED}"
212215
if [[ -z "${effective}" ]]; then
213216
effective="true"
214217
fi
215-
if [[ "${USE_RELEASE}" == "true" && "${EVENT_NAME}" == "push" && "${REF_NAME}" != "${DEFAULT_BRANCH}" ]] \
218+
if [[ "${USE_RELEASE}" == "true" && "${EVENT_NAME}" == "push" && "${CREATED}" == "true" ]] \
219+
&& [[ "${REF_NAME}" != "${DEFAULT_BRANCH}" ]] \
216220
&& [[ "${REF_NAME}" =~ ^[0-9]+\.[0-9]+(\.[0-9]+)?$ ]]; then
217221
effective="true"
218222
fi
219223
echo "effective_any_modified=${effective}" >> "$GITHUB_OUTPUT"
220224
225+
- name: Write check metadata
226+
if: always() && steps.effective-any-modified.outputs.effective_any_modified != ''
227+
run: |
228+
echo '${{ steps.effective-any-modified.outputs.effective_any_modified }}' > /tmp/effective_any_modified
229+
230+
- name: Upload check metadata
231+
if: always() && steps.effective-any-modified.outputs.effective_any_modified != ''
232+
uses: actions/upload-artifact@v7
233+
with:
234+
name: docs-build-check-metadata
235+
path: /tmp/effective_any_modified
236+
retention-days: 1
237+
221238
# This check skips the job when the workflow runs on a fork repo itself (e.g.
222239
# user/kibana), not when a fork PR targets upstream. Fork PRs to upstream run
223240
# fine because github.event.repository is the upstream repo (not a fork).

.github/workflows/docs-deploy.yml

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ on:
4545
use-release-branches:
4646
description: >
4747
When true, update-link-index runs for semver release branches (e.g. 9.4) as well as the default branch.
48-
Pair with the same flag on docs-build so links.json is produced on release pushes without docs/** changes.
48+
Pair with the same flag on docs-build so links.json is produced when a release branch is first created.
4949
type: boolean
5050
default: false
5151
required: false
@@ -63,6 +63,7 @@ jobs:
6363
&& github.event.repository.fork == false
6464
runs-on: ubuntu-latest
6565
permissions:
66+
actions: read
6667
contents: none
6768
pull-requests: read
6869
id-token: write
@@ -80,6 +81,17 @@ jobs:
8081
vale-files-match: ${{ steps.context.outputs.vale-files-match }}
8182
link-index-eligible: ${{ steps.link-index-branch.outputs.eligible }}
8283
steps:
84+
- name: Download check metadata
85+
id: download-metadata
86+
if: github.event.workflow_run.event == 'push'
87+
continue-on-error: true
88+
uses: actions/download-artifact@v8
89+
with:
90+
name: docs-build-check-metadata
91+
run-id: ${{ github.event.workflow_run.id }}
92+
path: /tmp/check-metadata
93+
github-token: ${{ github.token }}
94+
8395
- name: Resolve workflow run context
8496
id: context
8597
uses: actions/github-script@v9
@@ -109,8 +121,19 @@ jobs:
109121
110122
if (event === 'push') {
111123
core.setOutput('base-ref', headBranch);
112-
core.setOutput('has-changes', 'true');
113124
core.setOutput('vale-files-match', 'false');
125+
126+
let hasChanges = 'true';
127+
try {
128+
const fs = require('fs');
129+
const value = fs.readFileSync('/tmp/check-metadata/effective_any_modified', 'utf8').trim();
130+
hasChanges = value === 'false' ? 'false' : 'true';
131+
core.info(`Push has-changes from docs-build metadata: ${hasChanges}`);
132+
} catch (err) {
133+
core.warning(`Could not read check metadata: ${err.message} — falling back to has-changes=true`);
134+
}
135+
136+
core.setOutput('has-changes', hasChanges);
114137
return;
115138
}
116139

0 commit comments

Comments
 (0)