Skip to content

Commit

Permalink
Merge pull request MrSquaare#47 from MrSquaare/develop
Browse files Browse the repository at this point in the history
v3.0.0
  • Loading branch information
MrSquaare authored Oct 3, 2023
2 parents 00c44a7 + 6ea6d88 commit 7bfdda6
Show file tree
Hide file tree
Showing 10 changed files with 66 additions and 44 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
lib/
11 changes: 1 addition & 10 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,7 @@ module.exports = {
"plugin:prettier/recommended",
],
env: {
es2021: true,
es2022: true,
node: true,
},
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
},
plugins: ["@typescript-eslint", "prettier"],
rules: {
"prettier/prettier": ["warn"],
},
};
4 changes: 2 additions & 2 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
- macos-latest
- ubuntu-latest
node:
- 16
- 20

runs-on: ${{ matrix.os }}

Expand Down Expand Up @@ -39,7 +39,7 @@ jobs:
- macos-latest
- ubuntu-latest
node:
- 16
- 20

runs-on: ${{ matrix.os }}

Expand Down
28 changes: 23 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Setup SSH

- [About](#about)
- [Using](#using)
- [Environment variables](#environment-variables)
- [Outputs](#outputs)
- [Examples](#examples)
- [Contributing](#contributing)
- [License](#license)
Expand All @@ -17,7 +19,7 @@ Setup SSH

This GitHub action helps you to setup SSH.

It support Node.js 16+ for Linux and macOS runners.
It support Node.js 20+ for Linux and macOS runners.

## Using

Expand All @@ -32,12 +34,28 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Setup SSH
uses: MrSquaare/ssh-setup-action@v2
uses: MrSquaare/ssh-setup-action@v3
with:
host: github.com
private-key: ${{ secrets.SSH_PRIVATE_KEY }}
```
## Environment variables
This action exports the following environment variables:
- `SSH_PATH`: Path to SSH directory
- `SSH_AGENT_PID`: PID of SSH agent
- `SSH_AUTH_SOCK`: Path to SSH agent socket

## Outputs

This action set the following outputs:

- `ssh-path`: Path to SSH directory
- `ssh-agent-pid`: PID of SSH agent
- `ssh-auth-sock`: Path to SSH agent socket

## Examples

### Single key and clone
Expand All @@ -53,7 +71,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Setup SSH
uses: MrSquaare/ssh-setup-action@v2
uses: MrSquaare/ssh-setup-action@v3
with:
host: github.com
private-key: ${{ secrets.SSH_PRIVATE_KEY }}
Expand All @@ -74,13 +92,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Setup GitHub SSH
uses: MrSquaare/ssh-setup-action@v2
uses: MrSquaare/ssh-setup-action@v3
with:
host: github.com
private-key: ${{ secrets.SSH_PRIVATE_KEY_GITHUB }}
private-key-name: github
- name: Setup GitLab SSH
uses: MrSquaare/ssh-setup-action@v2
uses: MrSquaare/ssh-setup-action@v3
with:
host: gitlab.com
private-key: ${{ secrets.SSH_PRIVATE_KEY_GITLAB }}
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ inputs:
default: "id_rsa"
required: false
runs:
using: "node16"
using: "node20"
main: "lib/index.js"
post: 'lib/cleanup.js'
post-if: 'always()'
2 changes: 1 addition & 1 deletion lib/index.js

Large diffs are not rendered by default.

37 changes: 20 additions & 17 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 8 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ssh-setup-action",
"version": "2.1.0",
"version": "3.0.0",
"description": "Setup SSH",
"repository": {
"type": "git",
Expand All @@ -15,10 +15,12 @@
"main": "src/index.ts",
"scripts": {
"build": "ncc build src/index.ts -o lib -m",
"lint": "eslint .",
"format": "eslint --fix .",
"test": "sh ./test/test.sh"
},
"devDependencies": {
"@types/node": "^16.18.57",
"@types/node": "^20.8.2",
"@typescript-eslint/eslint-plugin": "^6.7.4",
"@typescript-eslint/parser": "^6.7.4",
"@vercel/ncc": "^0.38.0",
Expand All @@ -31,7 +33,10 @@
"dependencies": {
"@actions/core": "^1.10.1",
"@actions/exec": "^1.1.1",
"nanoid": "^4.0.2",
"nanoid": "^5.0.1",
"valid-filename": "^4.0.0"
},
"engines": {
"node": ">=20"
}
}
7 changes: 5 additions & 2 deletions src/cleanup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ try {
execFileSync("ssh-agent", ["-k"], { stdio: "inherit" });
} catch (error) {
if (error instanceof Error) {
console.log(error.message);
console.warn(
"Error stopping the SSH agent, proceeding anyway:",
error.message,
);
}
console.log("Error stopping the SSH agent, proceeding anyway");
console.warn("Error stopping the SSH agent, proceeding anyway");
}
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type ExecuteResult = {
async function execute(
command: string,
args: string[] = [],
options: im.ExecOptions = {}
options: im.ExecOptions = {},
): Promise<ExecuteResult> {
let stdout = "";
let stderr = "";
Expand Down Expand Up @@ -121,10 +121,10 @@ async function initializeSSHAgent(): Promise<SSHAgent> {
}

const pidMatch: RegExpMatchArray | null = stdout.match(
"SSH_AGENT_PID=(.*?);"
"SSH_AGENT_PID=(.*?);",
);
const socketMatch: RegExpMatchArray | null = stdout.match(
"SSH_AUTH_SOCK=(.*?);"
"SSH_AUTH_SOCK=(.*?);",
);

return {
Expand Down

0 comments on commit 7bfdda6

Please sign in to comment.