mirror of
https://github.com/crazy-max/ghaction-import-gpg.git
synced 2025-01-31 11:51:11 +01: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 gpg_1 = __webpack_require__(207);
|
||||||
const openpgp_1 = __webpack_require__(781);
|
const openpgp_1 = __webpack_require__(781);
|
||||||
const stateHelper = __importStar(__webpack_require__(153));
|
const stateHelper = __importStar(__webpack_require__(153));
|
||||||
let privateKey;
|
|
||||||
function run() {
|
function run() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
try {
|
||||||
|
@ -122,7 +121,7 @@ function run() {
|
||||||
core.debug(`SIGNING_KEY: ${process.env.SIGNING_KEY}`);
|
core.debug(`SIGNING_KEY: ${process.env.SIGNING_KEY}`);
|
||||||
core.debug(`PASSPHRASE: ${process.env.PASSPHRASE}`);
|
core.debug(`PASSPHRASE: ${process.env.PASSPHRASE}`);
|
||||||
core.info('🔮 Checking signing key...');
|
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.fingerprint=${privateKey.fingerprint}`);
|
||||||
core.debug(`key.keyID=${privateKey.keyID}`);
|
core.debug(`key.keyID=${privateKey.keyID}`);
|
||||||
core.debug(`key.userID=${privateKey.userID}`);
|
core.debug(`key.userID=${privateKey.userID}`);
|
||||||
|
@ -137,12 +136,13 @@ function run() {
|
||||||
}
|
}
|
||||||
function cleanup() {
|
function cleanup() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
if (!privateKey) {
|
if (!process.env.SIGNING_KEY) {
|
||||||
core.debug('Private key is not defined. Skipping cleanup.');
|
core.debug('Private key is not defined. Skipping cleanup.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
core.info('🚿 Removing keys from GnuPG...');
|
core.info('🚿 Removing keys from GnuPG...');
|
||||||
|
const privateKey = yield openpgp_1.readPrivateKey(process.env.SIGNING_KEY);
|
||||||
yield gpg_1.deleteKey(privateKey.fingerprint);
|
yield gpg_1.deleteKey(privateKey.fingerprint);
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import {deleteKey, importKey} from './gpg';
|
import {deleteKey, importKey} from './gpg';
|
||||||
import {PrivateKey, readPrivateKey} from './openpgp';
|
import {readPrivateKey} from './openpgp';
|
||||||
import * as stateHelper from './state-helper';
|
import * as stateHelper from './state-helper';
|
||||||
|
|
||||||
let privateKey: PrivateKey | undefined;
|
|
||||||
|
|
||||||
async function run(): Promise<void> {
|
async function run(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
if (!process.env.SIGNING_KEY) {
|
if (!process.env.SIGNING_KEY) {
|
||||||
|
@ -16,7 +14,7 @@ async function run(): Promise<void> {
|
||||||
core.debug(`PASSPHRASE: ${process.env.PASSPHRASE}`);
|
core.debug(`PASSPHRASE: ${process.env.PASSPHRASE}`);
|
||||||
|
|
||||||
core.info('🔮 Checking signing key...');
|
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.fingerprint=${privateKey.fingerprint}`);
|
||||||
core.debug(`key.keyID=${privateKey.keyID}`);
|
core.debug(`key.keyID=${privateKey.keyID}`);
|
||||||
core.debug(`key.userID=${privateKey.userID}`);
|
core.debug(`key.userID=${privateKey.userID}`);
|
||||||
|
@ -30,12 +28,13 @@ async function run(): Promise<void> {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function cleanup(): Promise<void> {
|
async function cleanup(): Promise<void> {
|
||||||
if (!privateKey) {
|
if (!process.env.SIGNING_KEY) {
|
||||||
core.debug('Private key is not defined. Skipping cleanup.');
|
core.debug('Private key is not defined. Skipping cleanup.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
core.info('🚿 Removing keys from GnuPG...');
|
core.info('🚿 Removing keys from GnuPG...');
|
||||||
|
const privateKey = await readPrivateKey(process.env.SIGNING_KEY);
|
||||||
await deleteKey(privateKey.fingerprint);
|
await deleteKey(privateKey.fingerprint);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.warning(error.message);
|
core.warning(error.message);
|
||||||
|
|
Loading…
Add table
Reference in a new issue