mirror of
https://github.com/crazy-max/ghaction-import-gpg.git
synced 2024-12-24 20:22:07 -05:00
Read private key on cleanup
This commit is contained in:
parent
ee885cc34c
commit
f5631011c6
2 changed files with 7 additions and 8 deletions
6
dist/index.js
generated
vendored
6
dist/index.js
generated
vendored
|
@ -111,7 +111,6 @@ const core = __importStar(__webpack_require__(470));
|
|||
const gpg_1 = __webpack_require__(207);
|
||||
const openpgp_1 = __webpack_require__(781);
|
||||
const stateHelper = __importStar(__webpack_require__(153));
|
||||
let privateKey;
|
||||
function run() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
try {
|
||||
|
@ -122,7 +121,7 @@ function run() {
|
|||
core.debug(`SIGNING_KEY: ${process.env.SIGNING_KEY}`);
|
||||
core.debug(`PASSPHRASE: ${process.env.PASSPHRASE}`);
|
||||
core.info('🔮 Checking signing key...');
|
||||
privateKey = yield openpgp_1.readPrivateKey(process.env.SIGNING_KEY);
|
||||
const privateKey = yield openpgp_1.readPrivateKey(process.env.SIGNING_KEY);
|
||||
core.debug(`key.fingerprint=${privateKey.fingerprint}`);
|
||||
core.debug(`key.keyID=${privateKey.keyID}`);
|
||||
core.debug(`key.userID=${privateKey.userID}`);
|
||||
|
@ -137,12 +136,13 @@ function run() {
|
|||
}
|
||||
function cleanup() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
if (!privateKey) {
|
||||
if (!process.env.SIGNING_KEY) {
|
||||
core.debug('Private key is not defined. Skipping cleanup.');
|
||||
return;
|
||||
}
|
||||
try {
|
||||
core.info('🚿 Removing keys from GnuPG...');
|
||||
const privateKey = yield openpgp_1.readPrivateKey(process.env.SIGNING_KEY);
|
||||
yield gpg_1.deleteKey(privateKey.fingerprint);
|
||||
}
|
||||
catch (error) {
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
import * as core from '@actions/core';
|
||||
import {deleteKey, importKey} from './gpg';
|
||||
import {PrivateKey, readPrivateKey} from './openpgp';
|
||||
import {readPrivateKey} from './openpgp';
|
||||
import * as stateHelper from './state-helper';
|
||||
|
||||
let privateKey: PrivateKey | undefined;
|
||||
|
||||
async function run(): Promise<void> {
|
||||
try {
|
||||
if (!process.env.SIGNING_KEY) {
|
||||
|
@ -16,7 +14,7 @@ async function run(): Promise<void> {
|
|||
core.debug(`PASSPHRASE: ${process.env.PASSPHRASE}`);
|
||||
|
||||
core.info('🔮 Checking signing key...');
|
||||
privateKey = await readPrivateKey(process.env.SIGNING_KEY);
|
||||
const privateKey = await readPrivateKey(process.env.SIGNING_KEY);
|
||||
core.debug(`key.fingerprint=${privateKey.fingerprint}`);
|
||||
core.debug(`key.keyID=${privateKey.keyID}`);
|
||||
core.debug(`key.userID=${privateKey.userID}`);
|
||||
|
@ -30,12 +28,13 @@ async function run(): Promise<void> {
|
|||
}
|
||||
|
||||
async function cleanup(): Promise<void> {
|
||||
if (!privateKey) {
|
||||
if (!process.env.SIGNING_KEY) {
|
||||
core.debug('Private key is not defined. Skipping cleanup.');
|
||||
return;
|
||||
}
|
||||
try {
|
||||
core.info('🚿 Removing keys from GnuPG...');
|
||||
const privateKey = await readPrivateKey(process.env.SIGNING_KEY);
|
||||
await deleteKey(privateKey.fingerprint);
|
||||
} catch (error) {
|
||||
core.warning(error.message);
|
||||
|
|
Loading…
Reference in a new issue