-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🦄🗯️ added ssh build with linting (#121) 🦄🗯️
- Loading branch information
1 parent
11f2ce2
commit 2cfdbf7
Showing
8 changed files
with
199 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
name: Build ssh-agent | ||
|
||
on: | ||
push: | ||
paths: | ||
- .github/workflows/ssh-agent-build.yaml | ||
- ssh-agent/** | ||
pull_request: | ||
paths: | ||
- .github/workflows/ssh-agent-build.yaml | ||
- ssh-agent/** | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16 | ||
|
||
- name: Install Node.js dependencies | ||
run: | | ||
pushd ssh-agent/ | ||
npm install | ||
npm i -g @vercel/ncc | ||
popd | ||
- name: Run linters | ||
uses: wearerequired/lint-action@v2 | ||
with: | ||
continue_on_error: false | ||
eslint_dir: ssh-agent/ | ||
eslint_auto_fix: false | ||
eslint: true | ||
prettier_dir: ssh-agent/ | ||
prettier_auto_fix: false | ||
prettier: true | ||
|
||
- name: Compile Node.js dependencies | ||
run: | | ||
pushd ssh-agent/ | ||
npm run compile | ||
popd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
env: | ||
node: true | ||
commonjs: true | ||
es2021: true | ||
extends: | ||
- eslint:recommended | ||
- prettier | ||
overrides: [] | ||
parserOptions: | ||
ecmaVersion: latest | ||
rules: {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
dist/ | ||
README.md | ||
action.yml | ||
.eslintrc.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,67 @@ | ||
const core = require('@actions/core') | ||
const proc = require('child_process') | ||
const fs = require('fs') | ||
const core = require("@actions/core"); | ||
const proc = require("child_process"); | ||
const fs = require("fs"); | ||
|
||
try { | ||
if(!fs.existsSync(`${process.env['HOME']}/.ssh`)) { | ||
fs.mkdirSync(`${process.env['HOME']}/.ssh`, {recursive: true}) | ||
} | ||
console.log("Building known hosts") | ||
proc.execSync( | ||
`ssh-keyscan -p ${core.getInput('ssh_port')} ${core.getInput('domain')} >> ${process.env['HOME']}/.ssh/known_hosts`, | ||
{ | ||
stdio: [null, null, null], | ||
timeout: 20000 | ||
} | ||
) | ||
console.log("Finished building known hosts!") | ||
console.log("Starting ssh-agent") | ||
sshOutput = proc.execFileSync(`ssh-agent`, ["-a", core.getInput('ssh_auth_sock')]) | ||
sshOutput.toString().split("\n").forEach((line) => { | ||
var regexp = /=(.*); /g; | ||
if (line.includes("SSH_AUTH_SOCK")) { | ||
const sock = regexp.exec(line)[1]; | ||
core.exportVariable("SSH_AUTH_SOCK", sock) | ||
console.log(`Agent socket is ${sock}`) | ||
} | ||
if (line.includes("SSH_AGENT_PID")) { | ||
const pid = regexp.exec(line)[1] | ||
core.exportVariable("SSH_AGENT_PID", pid) | ||
console.log(`Agent PID is ${pid}`) | ||
function run() { | ||
try { | ||
if (!fs.existsSync(`${process.env["HOME"]}/.ssh`)) { | ||
fs.mkdirSync(`${process.env["HOME"]}/.ssh`, { recursive: true }); | ||
} | ||
}) | ||
console.log("Exported agent variables") | ||
console.log("Started ssh-agent!") | ||
console.log("Adding identity") | ||
proc.execSync( | ||
"ssh-add -", | ||
{ | ||
|
||
console.log("Building known hosts"); | ||
|
||
proc.execSync( | ||
`ssh-keyscan -p ${core.getInput("ssh_port")} ${core.getInput( | ||
"domain" | ||
)} >> ${process.env["HOME"]}/.ssh/known_hosts`, | ||
{ | ||
stdio: [null, null, null], | ||
timeout: 20000, | ||
} | ||
); | ||
|
||
console.log("Finished building known hosts!"); | ||
console.log("Starting ssh-agent"); | ||
|
||
var sshOutput = proc.execFileSync(`ssh-agent`, [ | ||
"-a", | ||
core.getInput("ssh_auth_sock"), | ||
]); | ||
|
||
sshOutput | ||
.toString() | ||
.split("\n") | ||
.forEach((line) => { | ||
var regexp = /=(.*); /g; | ||
if (line.includes("SSH_AUTH_SOCK")) { | ||
const sock = regexp.exec(line)[1]; | ||
core.exportVariable("SSH_AUTH_SOCK", sock); | ||
console.log(`Agent socket is ${sock}`); | ||
} | ||
|
||
if (line.includes("SSH_AGENT_PID")) { | ||
const pid = regexp.exec(line)[1]; | ||
core.exportVariable("SSH_AGENT_PID", pid); | ||
console.log(`Agent PID is ${pid}`); | ||
} | ||
}); | ||
|
||
console.log("Exported agent variables"); | ||
console.log("Started ssh-agent!"); | ||
console.log("Adding identity"); | ||
|
||
proc.execSync("ssh-add -", { | ||
stdio: [null, null, null], | ||
input: core.getInput("private_key").trim() + "\n" | ||
} | ||
) | ||
console.log("Added identity!") | ||
console.log("ssh-agent is ready to use") | ||
} catch (error) { | ||
console.log("Encountered an error:") | ||
console.log(error.message) | ||
process.exit(1) | ||
} | ||
input: core.getInput("private_key").trim() + "\n", | ||
}); | ||
|
||
console.log("Added identity!"); | ||
console.log("ssh-agent is ready to use"); | ||
} catch (error) { | ||
console.log("Encountered an error:"); | ||
console.log(error.message); | ||
process.exit(1); | ||
} | ||
} | ||
|
||
run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters