Skip to content

Commit

Permalink
Allow Job Summary generation to be disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
bigdaz committed Jun 6, 2022
1 parent 306a7e4 commit 63bcd47
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
7 changes: 5 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down Expand Up @@ -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`.
Expand Down
10 changes: 8 additions & 2 deletions src/setup-gradle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
const gradleUserHome = await determineGradleUserHome(buildRootDirectory)
Expand All @@ -35,7 +40,6 @@ export async function setup(buildRootDirectory: string): Promise<void> {
}

export async function complete(): Promise<void> {
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
Expand All @@ -52,7 +56,9 @@ export async function complete(): Promise<void> {
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<string> {
Expand Down

0 comments on commit 63bcd47

Please sign in to comment.