Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 74 additions & 4 deletions .github/workflows/preview-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ jobs:
outputs:
any_modified: ${{ steps.check-files.outputs.any_modified }}
all_changed_files: ${{ steps.check-files.outputs.all_changed_files }}
added_files: ${{ steps.check-files.outputs.added_files }}
modified_files: ${{ steps.check-files.outputs.modified_files }}
deleted_files: ${{ steps.check-files.outputs.deleted_files }}
renamed_files: ${{ steps.check-files.outputs.renamed_files }}
added_files: ${{ steps.check-modified-file-detail.outputs.added_files }}
modified_files: ${{ steps.check-modified-file-detail.outputs.modified_files }}
deleted_files: ${{ steps.check-modified-file-detail.outputs.deleted_files }}
renamed_files: ${{ steps.check-modified-file-detail.outputs.renamed_files }}
steps:
- name: Checkout
if: contains(fromJSON('["push", "merge_group", "workflow_dispatch"]'), github.event_name)
Expand All @@ -139,6 +139,61 @@ jobs:
.github/**
README.md

- name: Get modified file detail
if: contains(fromJSON('["merge_group", "pull_request", "pull_request_target"]'), github.event_name)
id: check-modified-file-detail
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
env:
PATH_PATTERN: "${{ inputs.path-pattern != '' && inputs.path-pattern || '**' }}"
IGNORE_PATTERNS: |
${{ inputs.path-pattern-ignore }}
.github/**
README.md
with:
script: |
const pathPattern = process.env.PATH_PATTERN;
const ignorePatterns = process.env.IGNORE_PATTERNS;
const ignoreGlobber = await glob.create(ignorePatterns);
const ignoredPaths = new Set(await ignoreGlobber.glob());

const { owner, repo } = context.repo;
const pull_number = context.payload.pull_request.number;

const allFiles = await github.paginate(github.rest.pulls.listFiles, {
owner,
repo,
pull_number,
});

const filteredFiles = allFiles.filter(file => !ignoredPaths.has(file.filename));

const added = [];
const modified = [];
const deleted = [];
const renamed = [];

for (const file of filteredFiles) {
switch (file.status) {
case 'added':
added.push(file.filename);
break;
case 'modified':
modified.push(file.filename);
break;
case 'removed':
deleted.push(file.filename);
break;
case 'renamed':
renamed.push(`${file.previous_filename}:${file.filename}`);
break;
}
}

core.setOutput('added_files', added.join(' '));
core.setOutput('modified_files', modified.join(' '));
core.setOutput('deleted_files', deleted.join(' '));
core.setOutput('renamed_files', renamed.join(' '));

build:
if: github.event.repository.fork == false # Skip running the job on the fork itself (It still runs on PRs on the upstream from forks)
runs-on: ubuntu-latest
Expand Down Expand Up @@ -256,6 +311,21 @@ jobs:
run: |
dotnet run --project src/tooling/docs-builder -- diff validate

- name: 'Validate redirect rules'
if: >
env.MATCH == 'true'
&& (
github.repository != 'elastic/docs-builder'
&& (
steps.deployment.outputs.result
|| (
needs.check.outputs.any_modified == 'true'
&& github.event_name == 'merge_group'
)
)
)
uses: elastic/docs-builder/actions/diff-validate@main

# we run our artifact directly, please use the prebuild
# elastic/docs-builder@main GitHub Action for all other repositories!
- name: Build documentation
Expand Down
11 changes: 5 additions & 6 deletions actions/diff-validate/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ name: 'Validate Redirect Rules'
description: 'Validates consistency of the documentation changes in relation to redirect rules'

runs:
using: "composite"
steps:
- name: Validate Redirect Rules
uses: elastic/docs-builder@main
with:
command: "diff validate"
using: 'docker'
image: "docker://ghcr.io/elastic/docs-builder:edge"
args:
- "diff"
- "validate"
6 changes: 5 additions & 1 deletion docs/contribute/redirects.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ For API redirects, consult with the documentation engineering team on Slack (#el

For elastic.co/guide redirects, open a [web team request](http://ela.st/web-request).

## File location.
## Validation

Running `docs-builder diff validate` will give you feedback on whether all necessary redirect rules are in place after your changes. It will also run on pull requests.

## File location

Redirects are configured at the content set-level.
The configuration file should be located next to your `docset.yml` file:
Expand Down
Loading