@@ -117,10 +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-files .outputs.added_files }}
121- modified_files : ${{ steps.check-files .outputs.modified_files }}
122- deleted_files : ${{ steps.check-files .outputs.deleted_files }}
123- renamed_files : ${{ steps.check-files .outputs.renamed_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 }}
124124 steps :
125125 - name : Checkout
126126 if : contains(fromJSON('["push", "merge_group", "workflow_dispatch"]'), github.event_name)
@@ -139,6 +139,62 @@ jobs:
139139 .github/**
140140 README.md
141141
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 glob = require('@actions/glob');
155+ const pathPattern = process.env.PATH_PATTERN;
156+ const ignorePatterns = process.env.IGNORE_PATTERNS;
157+ const ignoreGlobber = await glob.create(ignorePatterns);
158+ const ignoredPaths = new Set(await ignoreGlobber.glob());
159+
160+ const { owner, repo } = context.repo;
161+ const pull_number = context.payload.pull_request.number;
162+
163+ const files = await github.paginate(github.rest.pulls.listFiles, {
164+ owner,
165+ repo,
166+ pull_number,
167+ });
168+
169+ const filteredFiles = allFiles.filter(file => !ignoredPaths.has(file.filename));
170+
171+ const added = [];
172+ const modified = [];
173+ const deleted = [];
174+ const renamed = [];
175+
176+ for (const file of filteredFiles) {
177+ switch (file.status) {
178+ case 'added':
179+ added.push(file.filename);
180+ break;
181+ case 'modified':
182+ modified.push(file.filename);
183+ break;
184+ case 'removed':
185+ deleted.push(file.filename);
186+ break;
187+ case 'renamed':
188+ renamed.push(`${file.previous_filename}:${file.filename}`);
189+ break;
190+ }
191+ }
192+
193+ core.setOutput('added_files', added.join(' '));
194+ core.setOutput('modified_files', modified.join(' '));
195+ core.setOutput('deleted_files', deleted.join(' '));
196+ core.setOutput('renamed_files', renamed.join(' '));
197+
142198 build :
143199 if : github.event.repository.fork == false # Skip running the job on the fork itself (It still runs on PRs on the upstream from forks)
144200 runs-on : ubuntu-latest
@@ -256,6 +312,21 @@ jobs:
256312 run : |
257313 dotnet run --project src/tooling/docs-builder -- diff validate
258314
315+ - name : ' Validate redirect rules'
316+ if : >
317+ env.MATCH == 'true'
318+ && (
319+ github.repository != 'elastic/docs-builder'
320+ && (
321+ steps.deployment.outputs.result
322+ || (
323+ needs.check.outputs.any_modified == 'true'
324+ && github.event_name == 'merge_group'
325+ )
326+ )
327+ )
328+ uses : elastic/docs-builder/actions/diff-validate@main
329+
259330 # we run our artifact directly, please use the prebuild
260331 # elastic/docs-builder@main GitHub Action for all other repositories!
261332 - name : Build documentation
0 commit comments