Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow GHES repository to support deploy key #680

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix that stderr redirection does not work on github actions runner
  • Loading branch information
Jimin Jeon committed Dec 15, 2021
commit 6b46496a866c6d0181ed4de2391c9a185ddf4d80
3 changes: 2 additions & 1 deletion __tests__/set-tokens.test.ts
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@ import * as io from '@actions/io';
jest.mock('@actions/exec', () => ({
exec: jest.fn(),
getExecOutput: jest.fn().mockReturnValue({
stderr: '# hostname',
stdout: 'hostinfo',
exitCode: 0
})
@@ -70,7 +71,7 @@ describe('setSSHKey()', () => {
const mockGetExecOutput = await exec.getExecOutput('');
expect(fs.writeFileSync).toHaveBeenCalledWith(
expect.stringContaining('known_hosts'),
mockGetExecOutput.stdout
mockGetExecOutput.stderr + mockGetExecOutput.stdout
);
});

8 changes: 6 additions & 2 deletions src/set-tokens.ts
Original file line number Diff line number Diff line change
@@ -25,8 +25,12 @@ export async function setSSHKey(inps: Inputs, publishRepo: string): Promise<stri
// ssh-keyscan -t rsa github.com or serverUrl >> ~/.ssh/known_hosts on Ubuntu
const foundKnownHostKey = await (async () => {
try {
return (await exec.getExecOutput('ssh-keyscan', ['-t', 'rsa', getServerUrl().host, '&>']))
.stdout;
const keyscanOutput = await exec.getExecOutput('ssh-keyscan', [
'-t',
'rsa',
getServerUrl().host
]);
return keyscanOutput.stderr + keyscanOutput.stdout;
} catch (e) {
return `\
# github.com:22 SSH-2.0-babeld-1f0633a6