@@ -117,6 +117,10 @@ jobs:
117117 outputs :
118118 any_modified : ${{ steps.check-files.outputs.any_modified }}
119119 all_changed_files : ${{ steps.check-files.outputs.all_changed_files }}
120+ added_files : ${{ steps.check-modified-file-detail.outputs.added_files }}
121+ modified_files : ${{ steps.check-modified-file-detail.outputs.modified_files }}
122+ deleted_files : ${{ steps.check-modified-file-detail.outputs.deleted_files }}
123+ renamed_files : ${{ steps.check-modified-file-detail.outputs.renamed_files }}
120124 steps :
121125 - name : Checkout
122126 if : contains(fromJSON('["push", "merge_group", "workflow_dispatch"]'), github.event_name)
@@ -135,6 +139,61 @@ jobs:
135139 .github/**
136140 README.md
137141
142+ - name : Get modified file detail
143+ if : contains(fromJSON('["merge_group", "pull_request", "pull_request_target"]'), github.event_name)
144+ id : check-modified-file-detail
145+ uses : actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
146+ env :
147+ PATH_PATTERN : " ${{ inputs.path-pattern != '' && inputs.path-pattern || '**' }}"
148+ IGNORE_PATTERNS : |
149+ ${{ inputs.path-pattern-ignore }}
150+ .github/**
151+ README.md
152+ with :
153+ script : |
154+ const pathPattern = process.env.PATH_PATTERN;
155+ const ignorePatterns = process.env.IGNORE_PATTERNS;
156+ const ignoreGlobber = await glob.create(ignorePatterns);
157+ const ignoredPaths = new Set(await ignoreGlobber.glob());
158+
159+ const { owner, repo } = context.repo;
160+ const pull_number = context.payload.pull_request.number;
161+
162+ const allFiles = await github.paginate(github.rest.pulls.listFiles, {
163+ owner,
164+ repo,
165+ pull_number,
166+ });
167+
168+ const filteredFiles = allFiles.filter(file => !ignoredPaths.has(file.filename));
169+
170+ const added = [];
171+ const modified = [];
172+ const deleted = [];
173+ const renamed = [];
174+
175+ for (const file of filteredFiles) {
176+ switch (file.status) {
177+ case 'added':
178+ added.push(file.filename);
179+ break;
180+ case 'modified':
181+ modified.push(file.filename);
182+ break;
183+ case 'removed':
184+ deleted.push(file.filename);
185+ break;
186+ case 'renamed':
187+ renamed.push(`${file.previous_filename}:${file.filename}`);
188+ break;
189+ }
190+ }
191+
192+ core.setOutput('added_files', added.join(' '));
193+ core.setOutput('modified_files', modified.join(' '));
194+ core.setOutput('deleted_files', deleted.join(' '));
195+ core.setOutput('renamed_files', renamed.join(' '));
196+
138197 build :
139198 if : github.event.repository.fork == false # Skip running the job on the fork itself (It still runs on PRs on the upstream from forks)
140199 runs-on : ubuntu-latest
@@ -149,6 +208,10 @@ jobs:
149208 env :
150209 GITHUB_PR_REF_NAME : ${{ github.event.pull_request.head.ref }}
151210 MATCH : ${{ needs.match.outputs.content-source-match }}
211+ ADDED_FILES : ${{ needs.check.outputs.added_files }}
212+ MODIFIED_FILES : ${{ needs.check.outputs.modified_files }}
213+ DELETED_FILES : ${{ needs.check.outputs.deleted_files }}
214+ RENAMED_FILES : ${{ needs.check.outputs.renamed_files }}
152215 needs :
153216 - check
154217 - match
@@ -234,6 +297,35 @@ jobs:
234297 && steps.deployment.outputs.result
235298 uses : elastic/docs-builder/.github/actions/bootstrap@main
236299
300+ - name : ' Validate redirect rules'
301+ if : >
302+ env.MATCH == 'true'
303+ && github.repository == 'elastic/docs-builder'
304+ && (
305+ steps.deployment.outputs.result
306+ || (
307+ needs.check.outputs.any_modified == 'true'
308+ && github.event_name == 'merge_group'
309+ )
310+ )
311+ run : |
312+ dotnet run --project src/tooling/docs-builder -- diff validate
313+
314+ - name : ' Validate redirect rules'
315+ if : >
316+ env.MATCH == 'true'
317+ && (
318+ github.repository != 'elastic/docs-builder'
319+ && (
320+ steps.deployment.outputs.result
321+ || (
322+ needs.check.outputs.any_modified == 'true'
323+ && github.event_name == 'merge_group'
324+ )
325+ )
326+ )
327+ uses : elastic/docs-builder/actions/diff-validate@main
328+
237329 # we run our artifact directly, please use the prebuild
238330 # elastic/docs-builder@main GitHub Action for all other repositories!
239331 - name : Build documentation
0 commit comments