Skip to content

Commit

Permalink
work around github library bug
Browse files Browse the repository at this point in the history
  • Loading branch information
fearphage committed Aug 11, 2021
1 parent 5200e89 commit 75ea411
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 13 deletions.
27 changes: 20 additions & 7 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1776,6 +1776,14 @@ module.exports = require("fs");

/***/ }),

/***/ 225:
/***/ ((module) => {

"use strict";
module.exports = require("fs/promises");

/***/ }),

/***/ 87:
/***/ ((module) => {

Expand Down Expand Up @@ -1857,13 +1865,14 @@ module.exports = require("util");
var __webpack_exports__ = {};
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
(() => {
const fs = __nccwpck_require__(747);
const fs = __nccwpck_require__(225);
const nodeExec = __nccwpck_require__(669).promisify(__nccwpck_require__(129).exec);

const core = __nccwpck_require__(186);
const exec = __nccwpck_require__(514);
const io = __nccwpck_require__(436);

const reVariables = /^(?<name>SH_AUTH_SOCK|SSH_AGENT_PID)=(?<value>[^;]+);/;
const reVariables = /^(?<name>SSH_AUTH_SOCK|SSH_AGENT_PID)=(?<value>[^;]+);/;

const run = async () => {
let exitCode;
Expand All @@ -1877,11 +1886,14 @@ const run = async () => {
return;
}

exitCode = await exec.exec('ssh-keyscan', ['-t', 'rsa', 'github.com'], {
silent: true,
outStream: fs.createWriteStream('~/.ssh/known_hosts'),
});
if (exitCode) {
// working around a GitHub toolkit bug
// https://github.com/actions/toolkit/issues/649
try {
const { stdout } = await nodeExec('ssh-keyscan -t rsa github.com');

await fs.writeFile('~/.ssh/known_hosts', stdout, { flags: 'a' });
}
catch (e) {
core.setFailed('ssh-keyscan failed');
return;
}
Expand All @@ -1904,6 +1916,7 @@ const run = async () => {

if (match) {
core.exportVariable(match.groups.name, match.groups.value);
core.info(`exported environment variable: ${match.groups.name}=${match.groups.value}`);
}
});

Expand Down
16 changes: 10 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const fs = require('fs');
const fs = require('fs/promises');
const nodeExec = require('util').promisify(require('child_process').exec);

const core = require('@actions/core');
const exec = require('@actions/exec');
Expand All @@ -18,11 +19,14 @@ const run = async () => {
return;
}

exitCode = await exec.exec('ssh-keyscan', ['-t', 'rsa', 'github.com'], {
silent: true,
outStream: fs.createWriteStream('~/.ssh/known_hosts'),
});
if (exitCode) {
// working around a GitHub toolkit bug
// https://github.com/actions/toolkit/issues/649
try {
const { stdout } = await nodeExec('ssh-keyscan -t rsa github.com');

await fs.writeFile('~/.ssh/known_hosts', stdout, { flags: 'a' });
}
catch (e) {
core.setFailed('ssh-keyscan failed');
return;
}
Expand Down

0 comments on commit 75ea411

Please sign in to comment.