mirror of
https://github.com/gradle/gradle-build-action.git
synced 2024-12-25 01:56:18 +08:00
Always initialize encryption key
This commit is contained in:
parent
c00a847f3f
commit
270f30ba56
@ -11,6 +11,9 @@ on:
|
||||
download-dist:
|
||||
type: boolean
|
||||
default: false
|
||||
secrets:
|
||||
GRADLE_ENCRYPTION_KEY:
|
||||
required: true
|
||||
|
||||
env:
|
||||
DOWNLOAD_DIST: ${{ inputs.download-dist }}
|
||||
|
12
dist/main/index.js
vendored
12
dist/main/index.js
vendored
@ -138610,6 +138610,10 @@ class GradleStateCache {
|
||||
const initScriptsDir = path_1.default.resolve(this.gradleUserHome, 'init.d');
|
||||
fs_1.default.mkdirSync(initScriptsDir, { recursive: true });
|
||||
this.initializeGradleUserHome(this.gradleUserHome, initScriptsDir);
|
||||
const encryptionKey = params.getCacheEncryptionKey();
|
||||
if (encryptionKey) {
|
||||
core.exportVariable('GRADLE_ENCRYPTION_KEY', encryptionKey);
|
||||
}
|
||||
}
|
||||
cacheOutputExists() {
|
||||
const cachesDir = path_1.default.resolve(this.gradleUserHome, 'caches');
|
||||
@ -138946,7 +138950,6 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.ConfigurationCacheEntryExtractor = exports.GradleHomeEntryExtractor = void 0;
|
||||
const path_1 = __importDefault(__nccwpck_require__(71017));
|
||||
const fs_1 = __importDefault(__nccwpck_require__(57147));
|
||||
const crypto_1 = __importDefault(__nccwpck_require__(6113));
|
||||
const core = __importStar(__nccwpck_require__(42186));
|
||||
const glob = __importStar(__nccwpck_require__(28090));
|
||||
const semver = __importStar(__nccwpck_require__(11383));
|
||||
@ -139184,8 +139187,6 @@ class ConfigurationCacheEntryExtractor extends AbstractEntryExtractor {
|
||||
this.markNotRestored(listener, 'Encryption Key was not provided');
|
||||
return;
|
||||
}
|
||||
const encryptionKey = this.getAESEncryptionKey();
|
||||
core.exportVariable('GRADLE_ENCRYPTION_KEY', encryptionKey);
|
||||
return yield _super.restore.call(this, listener);
|
||||
});
|
||||
}
|
||||
@ -139217,11 +139218,6 @@ class ConfigurationCacheEntryExtractor extends AbstractEntryExtractor {
|
||||
yield _super.extract.call(this, listener);
|
||||
});
|
||||
}
|
||||
getAESEncryptionKey() {
|
||||
const secret = params.getCacheEncryptionKey();
|
||||
const key = crypto_1.default.pbkdf2Sync(secret, '', 1000, 16, 'sha256');
|
||||
return key.toString('base64');
|
||||
}
|
||||
getExtractedCacheEntryDefinitions() {
|
||||
const groupedResults = this.getConfigCacheDirectoriesWithAssociatedBuildResults();
|
||||
return Object.entries(groupedResults).map(([configCachePath, pathResults]) => {
|
||||
|
2
dist/main/index.js.map
vendored
2
dist/main/index.js.map
vendored
File diff suppressed because one or more lines are too long
12
dist/post/index.js
vendored
12
dist/post/index.js
vendored
@ -136063,6 +136063,10 @@ class GradleStateCache {
|
||||
const initScriptsDir = path_1.default.resolve(this.gradleUserHome, 'init.d');
|
||||
fs_1.default.mkdirSync(initScriptsDir, { recursive: true });
|
||||
this.initializeGradleUserHome(this.gradleUserHome, initScriptsDir);
|
||||
const encryptionKey = params.getCacheEncryptionKey();
|
||||
if (encryptionKey) {
|
||||
core.exportVariable('GRADLE_ENCRYPTION_KEY', encryptionKey);
|
||||
}
|
||||
}
|
||||
cacheOutputExists() {
|
||||
const cachesDir = path_1.default.resolve(this.gradleUserHome, 'caches');
|
||||
@ -136399,7 +136403,6 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.ConfigurationCacheEntryExtractor = exports.GradleHomeEntryExtractor = void 0;
|
||||
const path_1 = __importDefault(__nccwpck_require__(71017));
|
||||
const fs_1 = __importDefault(__nccwpck_require__(57147));
|
||||
const crypto_1 = __importDefault(__nccwpck_require__(6113));
|
||||
const core = __importStar(__nccwpck_require__(42186));
|
||||
const glob = __importStar(__nccwpck_require__(28090));
|
||||
const semver = __importStar(__nccwpck_require__(11383));
|
||||
@ -136637,8 +136640,6 @@ class ConfigurationCacheEntryExtractor extends AbstractEntryExtractor {
|
||||
this.markNotRestored(listener, 'Encryption Key was not provided');
|
||||
return;
|
||||
}
|
||||
const encryptionKey = this.getAESEncryptionKey();
|
||||
core.exportVariable('GRADLE_ENCRYPTION_KEY', encryptionKey);
|
||||
return yield _super.restore.call(this, listener);
|
||||
});
|
||||
}
|
||||
@ -136670,11 +136671,6 @@ class ConfigurationCacheEntryExtractor extends AbstractEntryExtractor {
|
||||
yield _super.extract.call(this, listener);
|
||||
});
|
||||
}
|
||||
getAESEncryptionKey() {
|
||||
const secret = params.getCacheEncryptionKey();
|
||||
const key = crypto_1.default.pbkdf2Sync(secret, '', 1000, 16, 'sha256');
|
||||
return key.toString('base64');
|
||||
}
|
||||
getExtractedCacheEntryDefinitions() {
|
||||
const groupedResults = this.getConfigCacheDirectoriesWithAssociatedBuildResults();
|
||||
return Object.entries(groupedResults).map(([configCachePath, pathResults]) => {
|
||||
|
2
dist/post/index.js.map
vendored
2
dist/post/index.js.map
vendored
File diff suppressed because one or more lines are too long
@ -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…
x
Reference in New Issue
Block a user