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
15 changes: 4 additions & 11 deletions .github/workflows/preview-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,8 @@ jobs:
with:
ref: ${{ github.event.pull_request.head.sha || github.ref }}

- name: Get changed files
if: contains(fromJSON('["merge_group", "pull_request", "pull_request_target"]'), github.event_name)
id: check-files
uses: tj-actions/changed-files@d6e91a2266cdb9d62096cebf1e8546899c6aa18f # v45.0.6
with:
files: ${{ inputs.path-pattern != '' && inputs.path-pattern || '**' }}

- name: Checkout
if: startsWith(github.event_name, 'pull_request') && steps.check-files.outputs.any_modified == 'true'
if: startsWith(github.event_name, 'pull_request')
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.ref }}
Expand All @@ -77,7 +70,7 @@ jobs:
tool-cache: false

- name: Create Deployment
if: github.event_name == 'push' || (steps.check-files.outputs.any_modified == 'true' && startsWith(github.event_name, 'pull_request'))
if: github.event_name == 'push' || startsWith(github.event_name, 'pull_request')
uses: actions/github-script@v7
id: deployment
env:
Expand Down Expand Up @@ -144,7 +137,7 @@ jobs:
dotnet run --project src/docs-builder -- --strict --path-prefix "${PATH_PREFIX}"

- name: Build documentation
if: github.repository != 'elastic/docs-builder' && (steps.deployment.outputs.result || (steps.check-files.outputs.any_modified == 'true' && github.event_name == 'merge_group'))
if: github.repository != 'elastic/docs-builder' && (steps.deployment.outputs.result || github.event_name == 'merge_group')
uses: elastic/docs-builder@main
id: docs-build
continue-on-error: ${{ fromJSON(inputs.continue-on-error != '' && inputs.continue-on-error || 'false') }}
Expand All @@ -154,7 +147,7 @@ jobs:
metadata-only: ${{ fromJSON(inputs.metadata-only != '' && inputs.metadata-only || 'true') }}

- name: 'Validate Inbound Links'
if: ${{ !cancelled() && steps.docs-build.outputs.skip != 'true' && (steps.deployment.outputs.result || (steps.check-files.outputs.any_modified == 'true' && github.event_name == 'merge_group')) }}
if: ${{ !cancelled() && steps.docs-build.outputs.skip != 'true' && (steps.deployment.outputs.result || github.event_name == 'merge_group') }}
uses: elastic/docs-builder/actions/validate-inbound-local@main

- uses: elastic/docs-builder/.github/actions/aws-auth@main
Expand Down
24 changes: 12 additions & 12 deletions src/docs-assembler/Sourcing/RepositorySourcesFetcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,28 +89,28 @@ private Checkout CloneOrUpdateRepository(Repository repository, string name, Con
{
_logger.LogInformation("Pull: {Name}\t{Repository}\t{RelativePath}", name, repository, relativePath);
// --allow-unrelated-histories due to shallow clones not finding a common ancestor
ExecIn(name, checkoutFolder, "git", "pull", "--depth", "1", "--allow-unrelated-histories", "--no-ff");
ExecIn(checkoutFolder, "git", "pull", "--depth", "1", "--allow-unrelated-histories", "--no-ff");
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

head = Capture(checkoutFolder, "git", "rev-parse", "HEAD");
}
else
{
_logger.LogInformation("Checkout: {Name}\t{Repository}\t{RelativePath}", name, repository, relativePath);
if (repository.CheckoutStrategy == "full")
{
Exec(name, "git", "clone", repository.Origin, checkoutFolder.FullName,
Exec("git", "clone", repository.Origin, checkoutFolder.FullName,
"--depth", "1", "--single-branch",
"--branch", repository.CurrentBranch
);
}
else if (repository.CheckoutStrategy == "partial")
{
Exec(name,
Exec(
"git", "clone", "--filter=blob:none", "--no-checkout", repository.Origin, checkoutFolder.FullName
);

ExecIn(name, checkoutFolder, "git", "sparse-checkout", "set", "--cone");
ExecIn(name, checkoutFolder, "git", "checkout", repository.CurrentBranch);
ExecIn(name, checkoutFolder, "git", "sparse-checkout", "set", "docs");
ExecIn(checkoutFolder, "git", "sparse-checkout", "set", "--cone");
ExecIn(checkoutFolder, "git", "checkout", repository.CurrentBranch);
ExecIn(checkoutFolder, "git", "sparse-checkout", "set", "docs");
head = Capture(checkoutFolder, "git", "rev-parse", "HEAD");
}
}
Expand All @@ -125,17 +125,17 @@ private Checkout CloneOrUpdateRepository(Repository repository, string name, Con
};
}

private void Exec(string name, string binary, params string[] args) => ExecIn(name, null, binary, args);
private void Exec(string binary, params string[] args) => ExecIn(null, binary, args);

private void ExecIn(string name, IDirectoryInfo? workingDirectory, string binary, params string[] args)
private void ExecIn(IDirectoryInfo? workingDirectory, string binary, params string[] args)
{
var arguments = new StartArguments(binary, args)
var arguments = new ExecArguments(binary, args)
{
WorkingDirectory = workingDirectory?.FullName
};
var result = Proc.StartRedirected(arguments, new ConsoleLineHandler(_logger, name));
if (result.ExitCode != 0)
context.Collector.EmitError("", $"Exit code: {result.ExitCode} while executing {binary} {string.Join(" ", args)} in {workingDirectory}");
var result = Proc.Exec(arguments);
if (result != 0)
context.Collector.EmitError("", $"Exit code: {result} while executing {binary} {string.Join(" ", args)} in {workingDirectory}");
}

private string Capture(IDirectoryInfo? workingDirectory, string binary, params string[] args)
Expand Down