mirror of
https://github.com/crazy-max/ghaction-import-gpg.git
synced 2025-01-11 12:31:24 -05:00
Fix setOutput (#86)
Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
parent
5068739ab7
commit
d0df47e309
4 changed files with 53 additions and 9 deletions
32
__tests__/context.test.ts
Normal file
32
__tests__/context.test.ts
Normal file
|
@ -0,0 +1,32 @@
|
|||
import * as os from 'os';
|
||||
|
||||
import * as context from '../src/context';
|
||||
|
||||
describe('setOutput', () => {
|
||||
beforeEach(() => {
|
||||
process.stdout.write = jest.fn();
|
||||
});
|
||||
|
||||
it('setOutput produces the correct command', () => {
|
||||
context.setOutput('some output', 'some value');
|
||||
assertWriteCalls([`::set-output name=some output::some value${os.EOL}`]);
|
||||
});
|
||||
|
||||
it('setOutput handles bools', () => {
|
||||
context.setOutput('some output', false);
|
||||
assertWriteCalls([`::set-output name=some output::false${os.EOL}`]);
|
||||
});
|
||||
|
||||
it('setOutput handles numbers', () => {
|
||||
context.setOutput('some output', 1.01);
|
||||
assertWriteCalls([`::set-output name=some output::1.01${os.EOL}`]);
|
||||
});
|
||||
});
|
||||
|
||||
// Assert that process.stdout.write calls called only with the given arguments.
|
||||
function assertWriteCalls(calls: string[]): void {
|
||||
expect(process.stdout.write).toHaveBeenCalledTimes(calls.length);
|
||||
for (let i = 0; i < calls.length; i++) {
|
||||
expect(process.stdout.write).toHaveBeenNthCalledWith(i + 1, calls[i]);
|
||||
}
|
||||
}
|
16
dist/index.js
generated
vendored
16
dist/index.js
generated
vendored
|
@ -36,8 +36,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.getInputs = void 0;
|
||||
exports.setOutput = exports.getInputs = void 0;
|
||||
const core = __importStar(__webpack_require__(186));
|
||||
const command_1 = __webpack_require__(351);
|
||||
function getInputs() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
return {
|
||||
|
@ -54,6 +55,11 @@ function getInputs() {
|
|||
});
|
||||
}
|
||||
exports.getInputs = getInputs;
|
||||
// FIXME: Temp fix https://github.com/actions/toolkit/issues/777
|
||||
function setOutput(name, value) {
|
||||
command_1.issueCommand('set-output', { name }, value);
|
||||
}
|
||||
exports.setOutput = setOutput;
|
||||
//# sourceMappingURL=context.js.map
|
||||
|
||||
/***/ }),
|
||||
|
@ -440,10 +446,10 @@ function run() {
|
|||
}
|
||||
}
|
||||
core.info('🛒 Setting outputs...');
|
||||
core.setOutput('fingerprint', privateKey.fingerprint);
|
||||
core.setOutput('keyid', privateKey.keyID);
|
||||
core.setOutput('name', privateKey.name);
|
||||
core.setOutput('email', privateKey.email);
|
||||
context.setOutput('fingerprint', privateKey.fingerprint);
|
||||
context.setOutput('keyid', privateKey.keyID);
|
||||
context.setOutput('name', privateKey.name);
|
||||
context.setOutput('email', privateKey.email);
|
||||
if (inputs.gitUserSigningkey) {
|
||||
core.info('🔐 Setting GPG signing keyID for this Git repository');
|
||||
yield git.setConfig('user.signingkey', privateKey.keyID);
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import * as core from '@actions/core';
|
||||
import {issueCommand} from '@actions/core/lib/command';
|
||||
|
||||
export interface Inputs {
|
||||
gpgPrivateKey: string;
|
||||
|
@ -25,3 +26,8 @@ export async function getInputs(): Promise<Inputs> {
|
|||
workdir: core.getInput('workdir') || '.'
|
||||
};
|
||||
}
|
||||
|
||||
// FIXME: Temp fix https://github.com/actions/toolkit/issues/777
|
||||
export function setOutput(name: string, value: any): void {
|
||||
issueCommand('set-output', {name}, value);
|
||||
}
|
||||
|
|
|
@ -51,10 +51,10 @@ async function run(): Promise<void> {
|
|||
}
|
||||
|
||||
core.info('🛒 Setting outputs...');
|
||||
core.setOutput('fingerprint', privateKey.fingerprint);
|
||||
core.setOutput('keyid', privateKey.keyID);
|
||||
core.setOutput('name', privateKey.name);
|
||||
core.setOutput('email', privateKey.email);
|
||||
context.setOutput('fingerprint', privateKey.fingerprint);
|
||||
context.setOutput('keyid', privateKey.keyID);
|
||||
context.setOutput('name', privateKey.name);
|
||||
context.setOutput('email', privateKey.email);
|
||||
|
||||
if (inputs.gitUserSigningkey) {
|
||||
core.info('🔐 Setting GPG signing keyID for this Git repository');
|
||||
|
|
Loading…
Reference in a new issue