mirror of
https://github.com/crazy-max/ghaction-import-gpg.git
synced 2024-12-24 20:22:07 -05:00
Fix tmp path for signing key
This commit is contained in:
parent
070decda57
commit
297fd4647b
2 changed files with 23 additions and 13 deletions
23
dist/index.js
generated
vendored
23
dist/index.js
generated
vendored
|
@ -178,14 +178,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||
result["default"] = mod;
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const fs_1 = __webpack_require__(747);
|
||||
const child_process_1 = __importDefault(__webpack_require__(129));
|
||||
const child_process = __importStar(__webpack_require__(129));
|
||||
const fs = __importStar(__webpack_require__(747));
|
||||
const path = __importStar(__webpack_require__(622));
|
||||
const os = __importStar(__webpack_require__(87));
|
||||
const gpg = (args = []) => __awaiter(void 0, void 0, void 0, function* () {
|
||||
return child_process_1.default
|
||||
return child_process
|
||||
.execSync(`gpg ${args.join(' ')}`, {
|
||||
encoding: 'utf8'
|
||||
})
|
||||
|
@ -213,10 +219,11 @@ exports.getVersion = () => __awaiter(void 0, void 0, void 0, function* () {
|
|||
};
|
||||
});
|
||||
exports.importKey = (armoredText) => __awaiter(void 0, void 0, void 0, function* () {
|
||||
const keyPath = `${process.env.HOME}/key.pgp`;
|
||||
fs_1.writeFileSync(keyPath, armoredText, { mode: 0o600 });
|
||||
const keyFolder = fs.mkdtempSync(path.join(os.tmpdir(), 'ghaction-import-gpg-'));
|
||||
const keyPath = `${keyFolder}/key.pgp`;
|
||||
fs.writeFileSync(keyPath, armoredText, { mode: 0o600 });
|
||||
yield gpg(['--import', '--batch', '--yes', keyPath]).finally(() => {
|
||||
fs_1.unlinkSync(keyPath);
|
||||
fs.unlinkSync(keyPath);
|
||||
});
|
||||
});
|
||||
exports.deleteKey = (fingerprint) => __awaiter(void 0, void 0, void 0, function* () {
|
||||
|
|
13
src/gpg.ts
13
src/gpg.ts
|
@ -1,5 +1,7 @@
|
|||
import {unlinkSync, writeFileSync} from 'fs';
|
||||
import child_process from 'child_process';
|
||||
import * as child_process from 'child_process';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import * as os from 'os';
|
||||
|
||||
export interface Version {
|
||||
gnupg: string;
|
||||
|
@ -37,11 +39,12 @@ export const getVersion = async (): Promise<Version> => {
|
|||
};
|
||||
|
||||
export const importKey = async (armoredText: string): Promise<void> => {
|
||||
const keyPath: string = `${process.env.HOME}/key.pgp`;
|
||||
writeFileSync(keyPath, armoredText, {mode: 0o600});
|
||||
const keyFolder: string = fs.mkdtempSync(path.join(os.tmpdir(), 'ghaction-import-gpg-'));
|
||||
const keyPath: string = `${keyFolder}/key.pgp`;
|
||||
fs.writeFileSync(keyPath, armoredText, {mode: 0o600});
|
||||
|
||||
await gpg(['--import', '--batch', '--yes', keyPath]).finally(() => {
|
||||
unlinkSync(keyPath);
|
||||
fs.unlinkSync(keyPath);
|
||||
});
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue