diff --git a/action.yml b/action.yml index bfc4cf166..435febaf8 100644 --- a/action.yml +++ b/action.yml @@ -9,6 +9,9 @@ inputs: prefix: description: 'Path prefix for all urls' required: false + strict: + description: 'Treat warnings as errors' + required: false runs: using: 'docker' diff --git a/actions/publish/action.yml b/actions/publish/action.yml index 9d8161875..1252dd601 100644 --- a/actions/publish/action.yml +++ b/actions/publish/action.yml @@ -10,6 +10,11 @@ outputs: description: "The github actions url" value: ${{steps.deployment.outputs.page_url}} +inputs: + strict: + description: 'Treat warnings as errors' + required: false + runs: using: "composite" steps: @@ -20,6 +25,7 @@ runs: uses: elastic/docs-builder@main with: prefix: '${{ steps.repo-basename.outputs.value }}' + strict: ${{ inputs.strict }} - name: Setup Pages id: pages uses: actions/configure-pages@v5.0.0 diff --git a/src/docs-builder/Cli/Commands.cs b/src/docs-builder/Cli/Commands.cs index 522e07cda..9554b26ce 100644 --- a/src/docs-builder/Cli/Commands.cs +++ b/src/docs-builder/Cli/Commands.cs @@ -39,6 +39,7 @@ public async Task Serve(string? path = null, Cancel ctx = default) /// -o, Defaults to `.artifacts/html` /// Specifies the path prefix for urls /// Force a full rebuild of the destination folder + /// Treat warnings as errors and fail the build on warnings /// [Command("generate")] [ConsoleAppFilter] @@ -48,6 +49,7 @@ public async Task Generate( string? output = null, string? pathPrefix = null, bool? force = null, + bool? strict = null, Cancel ctx = default ) { @@ -62,7 +64,13 @@ public async Task Generate( var set = new DocumentationSet(context); var generator = new DocumentationGenerator(set, logger); await generator.GenerateAll(ctx); - return context.Collector.Errors + context.Collector.Warnings; + + if (bool.TryParse(githubActionsService.GetInput("strict"), out var strictValue) && strictValue) + strict ??= strictValue; + + if (strict ?? false) + return context.Collector.Errors + context.Collector.Warnings; + return context.Collector.Errors; } /// @@ -72,6 +80,7 @@ public async Task Generate( /// -o, Defaults to `.artifacts/html` /// Specifies the path prefix for urls /// Force a full rebuild of the destination folder + /// Treat warnings as errors and fail the build on warnings /// [Command("")] [ConsoleAppFilter] @@ -81,7 +90,8 @@ public async Task GenerateDefault( string? output = null, string? pathPrefix = null, bool? force = null, + bool? strict = null, Cancel ctx = default ) => - await Generate(path, output, pathPrefix, force, ctx); + await Generate(path, output, pathPrefix, force, strict, ctx); }