From 9285a5fef02d4f5f1c49300d59bca0111dd000d8 Mon Sep 17 00:00:00 2001 From: Martijn Laarman Date: Sat, 15 Mar 2025 11:53:21 +0100 Subject: [PATCH] Remove tj-actions usage, eventhough we had it pinned as gitref --- .github/workflows/preview-build.yml | 15 ++++-------- .../Sourcing/RepositorySourcesFetcher.cs | 24 +++++++++---------- 2 files changed, 16 insertions(+), 23 deletions(-) diff --git a/.github/workflows/preview-build.yml b/.github/workflows/preview-build.yml index 4737d580c..e477c5a72 100644 --- a/.github/workflows/preview-build.yml +++ b/.github/workflows/preview-build.yml @@ -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 }} @@ -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: @@ -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') }} @@ -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 diff --git a/src/docs-assembler/Sourcing/RepositorySourcesFetcher.cs b/src/docs-assembler/Sourcing/RepositorySourcesFetcher.cs index f7fc5d827..80aa4b515 100644 --- a/src/docs-assembler/Sourcing/RepositorySourcesFetcher.cs +++ b/src/docs-assembler/Sourcing/RepositorySourcesFetcher.cs @@ -89,7 +89,7 @@ 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"); head = Capture(checkoutFolder, "git", "rev-parse", "HEAD"); } else @@ -97,20 +97,20 @@ private Checkout CloneOrUpdateRepository(Repository repository, string name, Con _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"); } } @@ -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)