Skip to content

Commit a8a1d84

Browse files
committed
Revert Commands.cs
1 parent ad8841a commit a8a1d84

File tree

1 file changed

+29
-5
lines changed

1 file changed

+29
-5
lines changed

src/docs-builder/Cli/Commands.cs

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,36 @@ public async Task<int> Generate(
7474
pathPrefix ??= githubActionsService.GetInput("prefix");
7575
var fileSystem = new FileSystem();
7676
var collector = new ConsoleDiagnosticsCollector(logger, githubActionsService);
77-
var context = new BuildContext(collector, fileSystem, fileSystem, path, output)
77+
78+
var runningOnCi = !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("GITHUB_ACTIONS"));
79+
BuildContext context;
80+
try
81+
{
82+
context = new BuildContext(collector, fileSystem, fileSystem, path, output)
83+
{
84+
UrlPathPrefix = pathPrefix,
85+
Force = force ?? false,
86+
AllowIndexing = allowIndexing != null
87+
};
88+
}
89+
// On CI, we are running on merge commit which may have changes against an older
90+
// docs folder (this can happen on out of date PR's).
91+
// At some point in the future we can remove this try catch
92+
catch (Exception e) when (runningOnCi && e.Message.StartsWith("Can not locate docset.yml file in"))
7893
{
79-
UrlPathPrefix = pathPrefix,
80-
Force = force ?? false,
81-
AllowIndexing = allowIndexing != null
82-
};
94+
var outputDirectory = !string.IsNullOrWhiteSpace(output)
95+
? fileSystem.DirectoryInfo.New(output)
96+
: fileSystem.DirectoryInfo.New(Path.Combine(Paths.Root.FullName, ".artifacts/docs/html"));
97+
// we temporarily do not error when pointed to a non documentation folder.
98+
_ = fileSystem.Directory.CreateDirectory(outputDirectory.FullName);
99+
100+
ConsoleApp.Log($"Skipping build as we are running on a merge commit and the docs folder is out of date and has no docset.yml. {e.Message}");
101+
102+
await githubActionsService.SetOutputAsync("skip", "true");
103+
return 0;
104+
}
105+
if (runningOnCi)
106+
await githubActionsService.SetOutputAsync("skip", "false");
83107
var set = new DocumentationSet(context, logger);
84108
var generator = new DocumentationGenerator(set, logger);
85109
await generator.GenerateAll(ctx);

0 commit comments

Comments
 (0)