mirror of
https://github.com/gradle/gradle-build-action.git
synced 2025-06-07 16:56:12 +02:00
Add support for read-only caching in v2
This commit is contained in:
parent
d9cc0aeccf
commit
6fca6b3929
6 changed files with 53 additions and 35 deletions
|
@ -1,3 +1,28 @@
|
|||
import * as core from '@actions/core'
|
||||
|
||||
export function truncateArgs(args: string): string {
|
||||
return args.trim().replace(/\s+/g, ' ').substr(0, 400)
|
||||
}
|
||||
|
||||
export function isCacheReadEnabled(cacheName: string): boolean {
|
||||
const configValue = getCacheEnabledValue(cacheName)
|
||||
return configValue === 'true' || configValue === 'read-only'
|
||||
}
|
||||
|
||||
export function isCacheSaveEnabled(cacheName: string): boolean {
|
||||
const configValue = getCacheEnabledValue(cacheName)
|
||||
return configValue === 'true'
|
||||
}
|
||||
|
||||
function getCacheEnabledValue(cacheName: string): string {
|
||||
const configValue = core
|
||||
.getInput(`${cacheName}-cache-enabled`)
|
||||
.toLowerCase()
|
||||
|
||||
if (['true', 'false', 'read-only'].includes(configValue)) {
|
||||
return configValue
|
||||
}
|
||||
throw new Error(
|
||||
`Invalid cache-enabled parameter '${configValue}'. Valid values are ['true', 'false', 'read-only']`
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue