mirror of
https://github.com/gradle/gradle-build-action.git
synced 2024-11-22 16:20:59 -05:00
Add input to disable wrapper caching
This commit is contained in:
parent
3abad5567a
commit
02a8a21e55
4 changed files with 17 additions and 4 deletions
|
@ -20,6 +20,9 @@ inputs:
|
||||||
arguments:
|
arguments:
|
||||||
description: Gradle command line arguments, see gradle --help
|
description: Gradle command line arguments, see gradle --help
|
||||||
required: false
|
required: false
|
||||||
|
wrapper-cache-enabled:
|
||||||
|
description: Whether caching wrapper installation is enabled or not, default to 'true'
|
||||||
|
required: false
|
||||||
dependencies-cache-enabled:
|
dependencies-cache-enabled:
|
||||||
description: Whether caching dependencies is enabled or not, default to 'true'
|
description: Whether caching dependencies is enabled or not, default to 'true'
|
||||||
required: false
|
required: false
|
||||||
|
|
2
dist/main/index.js
vendored
2
dist/main/index.js
vendored
File diff suppressed because one or more lines are too long
2
dist/post/index.js
vendored
2
dist/post/index.js
vendored
File diff suppressed because one or more lines are too long
|
@ -1,9 +1,12 @@
|
||||||
import * as core from '@actions/core'
|
|
||||||
import * as cache from '@actions/cache'
|
|
||||||
import * as path from 'path'
|
import * as path from 'path'
|
||||||
import * as fs from 'fs'
|
import * as fs from 'fs'
|
||||||
import * as os from 'os'
|
import * as os from 'os'
|
||||||
|
|
||||||
|
import * as core from '@actions/core'
|
||||||
|
import * as cache from '@actions/cache'
|
||||||
|
|
||||||
|
import * as github from './github-utils'
|
||||||
|
|
||||||
const WRAPPER_CACHE_KEY = 'WRAPPER_CACHE_KEY'
|
const WRAPPER_CACHE_KEY = 'WRAPPER_CACHE_KEY'
|
||||||
const WRAPPER_CACHE_PATH = 'WRAPPER_CACHE_PATH'
|
const WRAPPER_CACHE_PATH = 'WRAPPER_CACHE_PATH'
|
||||||
const WRAPPER_CACHE_RESULT = 'WRAPPER_CACHE_RESULT'
|
const WRAPPER_CACHE_RESULT = 'WRAPPER_CACHE_RESULT'
|
||||||
|
@ -11,6 +14,7 @@ const WRAPPER_CACHE_RESULT = 'WRAPPER_CACHE_RESULT'
|
||||||
export async function restoreCachedWrapperDist(
|
export async function restoreCachedWrapperDist(
|
||||||
gradlewDirectory: string | null
|
gradlewDirectory: string | null
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
|
if (isWrapperCacheDisabled()) return
|
||||||
if (gradlewDirectory == null) return
|
if (gradlewDirectory == null) return
|
||||||
|
|
||||||
const wrapperSlug = extractGradleWrapperSlugFrom(
|
const wrapperSlug = extractGradleWrapperSlugFrom(
|
||||||
|
@ -48,6 +52,8 @@ export async function restoreCachedWrapperDist(
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function cacheWrapperDist(): Promise<void> {
|
export async function cacheWrapperDist(): Promise<void> {
|
||||||
|
if (isWrapperCacheDisabled()) return
|
||||||
|
|
||||||
const cacheKey = core.getState(WRAPPER_CACHE_KEY)
|
const cacheKey = core.getState(WRAPPER_CACHE_KEY)
|
||||||
const cachePath = core.getState(WRAPPER_CACHE_PATH)
|
const cachePath = core.getState(WRAPPER_CACHE_PATH)
|
||||||
const cacheResult = core.getState(WRAPPER_CACHE_RESULT)
|
const cacheResult = core.getState(WRAPPER_CACHE_RESULT)
|
||||||
|
@ -97,3 +103,7 @@ export function extractGradleWrapperSlugFromDistUri(
|
||||||
const match = distUri.match(regex)
|
const match = distUri.match(regex)
|
||||||
return match ? match[1] : null
|
return match ? match[1] : null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isWrapperCacheDisabled(): boolean {
|
||||||
|
return !github.inputBoolean('wrapper-cache-enabled', true)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue