mirror of
https://github.com/gradle/gradle-build-action.git
synced 2025-06-06 16:26:12 +02:00
Always initialize encryption key
This commit is contained in:
parent
c00a847f3f
commit
270f30ba56
7 changed files with 20 additions and 27 deletions
|
@ -26,6 +26,7 @@ export class GradleStateCache {
|
|||
}
|
||||
|
||||
init(): void {
|
||||
// Copy init-scripts to Gradle User Home
|
||||
const actionCacheDir = path.resolve(this.gradleUserHome, '.gradle-build-action')
|
||||
fs.mkdirSync(actionCacheDir, {recursive: true})
|
||||
|
||||
|
@ -33,6 +34,12 @@ export class GradleStateCache {
|
|||
fs.mkdirSync(initScriptsDir, {recursive: true})
|
||||
|
||||
this.initializeGradleUserHome(this.gradleUserHome, initScriptsDir)
|
||||
|
||||
// Export the GRADLE_ENCRYPTION_KEY variable if provided
|
||||
const encryptionKey = params.getCacheEncryptionKey()
|
||||
if (encryptionKey) {
|
||||
core.exportVariable('GRADLE_ENCRYPTION_KEY', encryptionKey)
|
||||
}
|
||||
}
|
||||
|
||||
cacheOutputExists(): boolean {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import path from 'path'
|
||||
import fs from 'fs'
|
||||
import crypto from 'crypto'
|
||||
import * as core from '@actions/core'
|
||||
import * as glob from '@actions/glob'
|
||||
import * as semver from 'semver'
|
||||
|
@ -383,8 +382,6 @@ export class ConfigurationCacheEntryExtractor extends AbstractEntryExtractor {
|
|||
return
|
||||
}
|
||||
|
||||
const encryptionKey = this.getAESEncryptionKey()
|
||||
core.exportVariable('GRADLE_ENCRYPTION_KEY', encryptionKey)
|
||||
return await super.restore(listener)
|
||||
}
|
||||
|
||||
|
@ -416,12 +413,6 @@ export class ConfigurationCacheEntryExtractor extends AbstractEntryExtractor {
|
|||
await super.extract(listener)
|
||||
}
|
||||
|
||||
private getAESEncryptionKey(): string | undefined {
|
||||
const secret = params.getCacheEncryptionKey()
|
||||
const key = crypto.pbkdf2Sync(secret, '', 1000, 16, 'sha256')
|
||||
return key.toString('base64')
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract cache entries for the configuration cache in each project.
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue