diff --git a/actions/assembler-match/action.yml b/actions/assembler-match/action.yml index 112e421f2..8091bc141 100644 --- a/actions/assembler-match/action.yml +++ b/actions/assembler-match/action.yml @@ -18,6 +18,10 @@ outputs: description: 'true/false indicating the branch matches a content-source' content-source-name: description: "The name of the content source that matches (current/next) or empty" + content-source-next: + description: "true/false indicating the branch acts as the next content source" + content-source-current: + description: "true/false indicating the branch acts as the current content source" runs: using: 'docker' diff --git a/src/Elastic.Documentation.Configuration/Assembler/AssemblyConfiguration.cs b/src/Elastic.Documentation.Configuration/Assembler/AssemblyConfiguration.cs index 652465f01..8a2ea01a3 100644 --- a/src/Elastic.Documentation.Configuration/Assembler/AssemblyConfiguration.cs +++ b/src/Elastic.Documentation.Configuration/Assembler/AssemblyConfiguration.cs @@ -81,26 +81,29 @@ private static TRepository RepositoryDefaults(TRepository r, string /// Returns whether the is configured as an integration branch or tag for the given /// . - public ContentSource? Match(string repository, string branchOrTag) + public ContentSourceMatch Match(string repository, string branchOrTag) { var repositoryName = repository.Split('/').Last(); + var match = new ContentSourceMatch(null, null); if (ReferenceRepositories.TryGetValue(repositoryName, out var r)) { if (r.GetBranch(ContentSource.Current) == branchOrTag) - return ContentSource.Current; + match = match with { Current = ContentSource.Current }; if (r.GetBranch(ContentSource.Next) == branchOrTag) - return ContentSource.Next; - return null; + match = match with { Next = ContentSource.Next }; + return match; } - if (repositoryName == NarrativeRepository.RepositoryName) - { - if (Narrative.GetBranch(ContentSource.Current) == branchOrTag) - return ContentSource.Current; - if (Narrative.GetBranch(ContentSource.Next) == branchOrTag) - return ContentSource.Next; - } + if (repositoryName != NarrativeRepository.RepositoryName) + return match; - return null; + if (Narrative.GetBranch(ContentSource.Current) == branchOrTag) + match = match with { Current = ContentSource.Current }; + if (Narrative.GetBranch(ContentSource.Next) == branchOrTag) + match = match with { Next = ContentSource.Next }; + + return match; } + + public record ContentSourceMatch(ContentSource? Current, ContentSource? Next); } diff --git a/src/tooling/docs-assembler/Cli/ContentSourceCommands.cs b/src/tooling/docs-assembler/Cli/ContentSourceCommands.cs index f8e0df118..6b0e22065 100644 --- a/src/tooling/docs-assembler/Cli/ContentSourceCommands.cs +++ b/src/tooling/docs-assembler/Cli/ContentSourceCommands.cs @@ -55,7 +55,7 @@ public async Task Match([Argument] string? repository = null, [Argument] st AllowIndexing = false }; var matches = assembleContext.Configuration.Match(repo, refName); - if (matches == null) + if (matches is { Current: null, Next: null }) { logger.LogInformation("'{Repository}' '{BranchOrTag}' combination not found in configuration.", repo, refName); await githubActionsService.SetOutputAsync("content-source-match", "false"); @@ -63,10 +63,17 @@ public async Task Match([Argument] string? repository = null, [Argument] st } else { - var name = matches.Value.ToStringFast(true); - logger.LogInformation("'{Repository}' '{BranchOrTag}' is configured as '{Matches}' content-source", repo, refName, name); + if (matches.Current is { } current) + logger.LogInformation("'{Repository}' '{BranchOrTag}' is configured as '{Matches}' content-source", repo, refName, current.ToStringFast(true)); + if (matches.Next is { } next) + logger.LogInformation("'{Repository}' '{BranchOrTag}' is configured as '{Matches}' content-source", repo, refName, next.ToStringFast(true)); await githubActionsService.SetOutputAsync("content-source-match", "true"); + await githubActionsService.SetOutputAsync("content-source-next", matches.Next is not null ? "true" : "false"); + await githubActionsService.SetOutputAsync("content-source-current", matches.Current is not null ? "true" : "false"); + + //TODO remove once we've merged our changes to the github action and its workflow usage to no longer use this output + var name = (matches.Current ?? matches.Next)!.Value.ToStringFast(true); await githubActionsService.SetOutputAsync("content-source-name", name); }