From 63bcd47c1be270a660a151ce2b7848b8730f06ef Mon Sep 17 00:00:00 2001 From: Daz DeBoer Date: Mon, 6 Jun 2022 07:13:23 -0600 Subject: [PATCH] Allow Job Summary generation to be disabled --- action.yml | 7 +++++-- src/setup-gradle.ts | 10 ++++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/action.yml b/action.yml index 02e3c09..2626a9b 100644 --- a/action.yml +++ b/action.yml @@ -19,8 +19,6 @@ inputs: By default this value is 'false' for workflows on the GitHub default branch and 'true' for workflows on other branches. required: false default: ${{ github.ref_name != github.event.repository.default_branch }} - # e.g. Use the following setting to only write cache entries from your 'main' branch - # cache-read-only: ${{ github.ref_name != 'main' }} cache-write-only: description: | @@ -55,6 +53,11 @@ inputs: description: Path to the Gradle executable required: false + generate-job-summary: + description: When 'false', no Job Summary will be generated for the Job. + required: false + default: true + # EXPERIMENTAL & INTERNAL ACTION INPUTS # The following action properties allow fine-grained tweaking of the action caching behaviour. # These properties are experimental and not (yet) designed for production use, and may change without notice in a subsequent release of `gradle-build-action`. diff --git a/src/setup-gradle.ts b/src/setup-gradle.ts index fc316c7..d13713f 100644 --- a/src/setup-gradle.ts +++ b/src/setup-gradle.ts @@ -11,6 +11,11 @@ import {BuildResult, loadBuildResults, writeJobSummary} from './job-summary' const GRADLE_SETUP_VAR = 'GRADLE_BUILD_ACTION_SETUP_COMPLETED' const GRADLE_USER_HOME = 'GRADLE_USER_HOME' const CACHE_LISTENER = 'CACHE_LISTENER' +const JOB_SUMMARY_ENABLED_PARAMETER = 'generate-job-summary' + +function generateJobSummary(): boolean { + return core.getBooleanInput(JOB_SUMMARY_ENABLED_PARAMETER) +} export async function setup(buildRootDirectory: string): Promise { const gradleUserHome = await determineGradleUserHome(buildRootDirectory) @@ -35,7 +40,6 @@ export async function setup(buildRootDirectory: string): Promise { } export async function complete(): Promise { - core.info('Inside setupGradle.complete()') if (!core.getState(GRADLE_SETUP_VAR)) { core.info('Gradle setup post-action only performed for first gradle-build-action step in workflow.') return @@ -52,7 +56,9 @@ export async function complete(): Promise { const gradleUserHome = core.getState(GRADLE_USER_HOME) await caches.save(gradleUserHome, cacheListener) - writeJobSummary(buildResults, cacheListener) + if (generateJobSummary()) { + writeJobSummary(buildResults, cacheListener) + } } async function determineGradleUserHome(rootDir: string): Promise {