mirror of
https://github.com/actions/setup-java.git
synced 2025-04-20 01:46:46 +00:00
changed gpg import to run in key directory
This commit is contained in:
parent
14d3f1d12c
commit
01f7e3b3fd
3 changed files with 13 additions and 9 deletions
|
@ -23,7 +23,7 @@ const env = process.env;
|
||||||
const m2Dir = path.join(__dirname, auth.M2_DIR);
|
const m2Dir = path.join(__dirname, auth.M2_DIR);
|
||||||
const settingsFile = path.join(m2Dir, auth.SETTINGS_FILE);
|
const settingsFile = path.join(m2Dir, auth.SETTINGS_FILE);
|
||||||
const gpgDir = path.join(__dirname, auth.GPG_DIR);
|
const gpgDir = path.join(__dirname, auth.GPG_DIR);
|
||||||
const gpgFile = path.join(gpgDir, auth.GPG_FILE);
|
const gpgFile = auth.GPG_FILE;
|
||||||
|
|
||||||
describe('auth tests', () => {
|
describe('auth tests', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
|
@ -180,7 +180,11 @@ describe('auth tests', () => {
|
||||||
|
|
||||||
await auth.configAuthentication(id, username, password, gpgPrivateKey);
|
await auth.configAuthentication(id, username, password, gpgPrivateKey);
|
||||||
|
|
||||||
expect(exec.exec).toHaveBeenCalledWith(`gpg --import --batch ${gpgFile}`);
|
expect(exec.exec).toHaveBeenCalledWith(
|
||||||
|
'gpg',
|
||||||
|
['--import', '--batch', gpgFile],
|
||||||
|
{cwd: gpgDir}
|
||||||
|
);
|
||||||
|
|
||||||
expect(fs.existsSync(gpgDir)).toBe(false);
|
expect(fs.existsSync(gpgDir)).toBe(false);
|
||||||
}, 100000);
|
}, 100000);
|
||||||
|
@ -193,7 +197,9 @@ describe('auth tests', () => {
|
||||||
await auth.configAuthentication(id, username, password);
|
await auth.configAuthentication(id, username, password);
|
||||||
|
|
||||||
expect(exec.exec).not.toHaveBeenCalledWith(
|
expect(exec.exec).not.toHaveBeenCalledWith(
|
||||||
`gpg --import --batch ${gpgFile}`
|
'gpg',
|
||||||
|
['--import', '--batch', gpgFile],
|
||||||
|
{cwd: gpgDir}
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(fs.existsSync(gpgDir)).toBe(false);
|
expect(fs.existsSync(gpgDir)).toBe(false);
|
||||||
|
|
5
dist/index.js
generated
vendored
5
dist/index.js
generated
vendored
|
@ -2887,8 +2887,8 @@ exports.GPG_FILE = 'private.asc';
|
||||||
exports.DEFAULT_ID = 'github';
|
exports.DEFAULT_ID = 'github';
|
||||||
exports.DEFAULT_USERNAME = 'GITHUB_ACTOR';
|
exports.DEFAULT_USERNAME = 'GITHUB_ACTOR';
|
||||||
exports.DEFAULT_PASSWORD = 'GITHUB_TOKEN';
|
exports.DEFAULT_PASSWORD = 'GITHUB_TOKEN';
|
||||||
exports.DEFAULT_GPG_PASSPHRASE = 'GPG_PASSPHRASE';
|
|
||||||
exports.DEFAULT_GPG_PRIVATE_KEY = '';
|
exports.DEFAULT_GPG_PRIVATE_KEY = '';
|
||||||
|
exports.DEFAULT_GPG_PASSPHRASE = 'GPG_PASSPHRASE';
|
||||||
function configAuthentication(id = exports.DEFAULT_ID, username = exports.DEFAULT_USERNAME, password = exports.DEFAULT_PASSWORD, gpgPrivateKey = exports.DEFAULT_GPG_PRIVATE_KEY, gpgPassphrase = exports.DEFAULT_GPG_PASSPHRASE) {
|
function configAuthentication(id = exports.DEFAULT_ID, username = exports.DEFAULT_USERNAME, password = exports.DEFAULT_PASSWORD, gpgPrivateKey = exports.DEFAULT_GPG_PRIVATE_KEY, gpgPassphrase = exports.DEFAULT_GPG_PASSPHRASE) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
console.log(`creating ${exports.SETTINGS_FILE} with server-id: ${id};`, 'environment variables:', `username=\$${username},`, `password=\$${password},`, `and gpg-passphrase=\$${gpgPassphrase}`);
|
console.log(`creating ${exports.SETTINGS_FILE} with server-id: ${id};`, 'environment variables:', `username=\$${username},`, `password=\$${password},`, `and gpg-passphrase=\$${gpgPassphrase}`);
|
||||||
|
@ -2961,8 +2961,7 @@ function write(directory, file, contents) {
|
||||||
}
|
}
|
||||||
function importGpgKey(directory, file) {
|
function importGpgKey(directory, file) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const location = path.join(directory, file);
|
exec.exec('gpg', ['--import', '--batch', file], { cwd: directory });
|
||||||
exec.exec(`gpg --import --batch ${location}`);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,8 +13,8 @@ export const GPG_FILE = 'private.asc';
|
||||||
export const DEFAULT_ID = 'github';
|
export const DEFAULT_ID = 'github';
|
||||||
export const DEFAULT_USERNAME = 'GITHUB_ACTOR';
|
export const DEFAULT_USERNAME = 'GITHUB_ACTOR';
|
||||||
export const DEFAULT_PASSWORD = 'GITHUB_TOKEN';
|
export const DEFAULT_PASSWORD = 'GITHUB_TOKEN';
|
||||||
export const DEFAULT_GPG_PASSPHRASE = 'GPG_PASSPHRASE';
|
|
||||||
export const DEFAULT_GPG_PRIVATE_KEY = '';
|
export const DEFAULT_GPG_PRIVATE_KEY = '';
|
||||||
|
export const DEFAULT_GPG_PASSPHRASE = 'GPG_PASSPHRASE';
|
||||||
|
|
||||||
export async function configAuthentication(
|
export async function configAuthentication(
|
||||||
id = DEFAULT_ID,
|
id = DEFAULT_ID,
|
||||||
|
@ -110,6 +110,5 @@ async function write(directory: string, file: string, contents: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function importGpgKey(directory: string, file: string) {
|
async function importGpgKey(directory: string, file: string) {
|
||||||
const location = path.join(directory, file);
|
exec.exec('gpg', ['--import', '--batch', file], {cwd: directory});
|
||||||
exec.exec(`gpg --import --batch ${location}`);
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue