Allow Job Summary generation to be disabled

This commit is contained in:
Daz DeBoer 2022-06-06 07:13:23 -06:00
parent 306a7e4bb2
commit 63bcd47c1b
No known key found for this signature in database
GPG Key ID: DD6B9F0B06683D5D
2 changed files with 13 additions and 4 deletions

View File

@ -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. By default this value is 'false' for workflows on the GitHub default branch and 'true' for workflows on other branches.
required: false required: false
default: ${{ github.ref_name != github.event.repository.default_branch }} 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: cache-write-only:
description: | description: |
@ -55,6 +53,11 @@ inputs:
description: Path to the Gradle executable description: Path to the Gradle executable
required: false 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 # EXPERIMENTAL & INTERNAL ACTION INPUTS
# The following action properties allow fine-grained tweaking of the action caching behaviour. # 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`. # These properties are experimental and not (yet) designed for production use, and may change without notice in a subsequent release of `gradle-build-action`.

View File

@ -11,6 +11,11 @@ import {BuildResult, loadBuildResults, writeJobSummary} from './job-summary'
const GRADLE_SETUP_VAR = 'GRADLE_BUILD_ACTION_SETUP_COMPLETED' const GRADLE_SETUP_VAR = 'GRADLE_BUILD_ACTION_SETUP_COMPLETED'
const GRADLE_USER_HOME = 'GRADLE_USER_HOME' const GRADLE_USER_HOME = 'GRADLE_USER_HOME'
const CACHE_LISTENER = 'CACHE_LISTENER' 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<void> { export async function setup(buildRootDirectory: string): Promise<void> {
const gradleUserHome = await determineGradleUserHome(buildRootDirectory) const gradleUserHome = await determineGradleUserHome(buildRootDirectory)
@ -35,7 +40,6 @@ export async function setup(buildRootDirectory: string): Promise<void> {
} }
export async function complete(): Promise<void> { export async function complete(): Promise<void> {
core.info('Inside setupGradle.complete()')
if (!core.getState(GRADLE_SETUP_VAR)) { if (!core.getState(GRADLE_SETUP_VAR)) {
core.info('Gradle setup post-action only performed for first gradle-build-action step in workflow.') core.info('Gradle setup post-action only performed for first gradle-build-action step in workflow.')
return return
@ -52,7 +56,9 @@ export async function complete(): Promise<void> {
const gradleUserHome = core.getState(GRADLE_USER_HOME) const gradleUserHome = core.getState(GRADLE_USER_HOME)
await caches.save(gradleUserHome, cacheListener) await caches.save(gradleUserHome, cacheListener)
writeJobSummary(buildResults, cacheListener) if (generateJobSummary()) {
writeJobSummary(buildResults, cacheListener)
}
} }
async function determineGradleUserHome(rootDir: string): Promise<string> { async function determineGradleUserHome(rootDir: string): Promise<string> {