From a7fb0ed92faee0ae0b85e22a1b19810be1cd4c3f Mon Sep 17 00:00:00 2001 From: Jose Celano Date: Mon, 28 Feb 2022 13:33:52 +0000 Subject: [PATCH] Delete key using primary key ID not subkey ID --- dist/index.js | 10 ++++++++-- src/main.ts | 3 ++- src/state-helper.ts | 5 +++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/dist/index.js b/dist/index.js index 72668ccf..290dd081 100644 --- a/dist/index.js +++ b/dist/index.js @@ -444,6 +444,7 @@ function run() { fingerprint = inputs.fingerprint; } stateHelper.setFingerprint(fingerprint); + stateHelper.setKeyID(privateKey.keyID); yield core.group(`Fingerprint to use`, () => __awaiter(this, void 0, void 0, function* () { core.info(fingerprint); })); @@ -526,7 +527,7 @@ function cleanup() { } try { core.info('Removing keys'); - yield gpg.deleteKey(stateHelper.fingerprint); + yield gpg.deleteKey(stateHelper.keyId); core.info('Killing GnuPG agent'); yield gpg.killAgent(); } @@ -644,14 +645,19 @@ var __importStar = (this && this.__importStar) || function (mod) { return result; }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.setFingerprint = exports.fingerprint = exports.IsPost = void 0; +exports.setKeyID = exports.setFingerprint = exports.keyId = exports.fingerprint = exports.IsPost = void 0; const core = __importStar(__webpack_require__(2186)); exports.IsPost = !!process.env['STATE_isPost']; exports.fingerprint = process.env['STATE_fingerprint'] || ''; +exports.keyId = process.env['STATE_keyId'] || ''; function setFingerprint(fingerprint) { core.saveState('fingerprint', fingerprint); } exports.setFingerprint = setFingerprint; +function setKeyID(keyID) { + core.saveState('keyId', keyID); +} +exports.setKeyID = setKeyID; if (!exports.IsPost) { core.saveState('isPost', 'true'); } diff --git a/src/main.ts b/src/main.ts index 840c436e..40aa4c91 100644 --- a/src/main.ts +++ b/src/main.ts @@ -38,6 +38,7 @@ async function run(): Promise { fingerprint = inputs.fingerprint; } stateHelper.setFingerprint(fingerprint); + stateHelper.setKeyID(privateKey.keyID); await core.group(`Fingerprint to use`, async () => { core.info(fingerprint); }); @@ -131,7 +132,7 @@ async function cleanup(): Promise { } try { core.info('Removing keys'); - await gpg.deleteKey(stateHelper.fingerprint); + await gpg.deleteKey(stateHelper.keyId); core.info('Killing GnuPG agent'); await gpg.killAgent(); diff --git a/src/state-helper.ts b/src/state-helper.ts index 09b43374..581430cf 100644 --- a/src/state-helper.ts +++ b/src/state-helper.ts @@ -2,11 +2,16 @@ import * as core from '@actions/core'; export const IsPost = !!process.env['STATE_isPost']; export const fingerprint = process.env['STATE_fingerprint'] || ''; +export const keyId = process.env['STATE_keyId'] || ''; export function setFingerprint(fingerprint: string) { core.saveState('fingerprint', fingerprint); } +export function setKeyID(keyID: string) { + core.saveState('keyId', keyID); +} + if (!IsPost) { core.saveState('isPost', 'true'); }