Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions .codacy.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
exclude_paths:
- 'lib/**'
- 'node_modules/**'
- "lib/**"
- "node_modules/**"
18 changes: 18 additions & 0 deletions .github/actions/setup-env/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: "Setup environment"
description: "Setup environment"

runs:
using: "composite"
steps:
- name: Install pnpm
uses: pnpm/action-setup@v4

- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 20
cache: "pnpm"

- name: Install dependencies
shell: bash
run: pnpm install
55 changes: 26 additions & 29 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,39 @@
name: Pull Request

on: [pull_request, workflow_dispatch]
on:
pull_request:
branches:
- main
workflow_dispatch:

jobs:
checks:
name: Checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6

- name: Setup environment
uses: ./.github/actions/setup-env

- name: Check lint and format
run: |
pnpm check

build:
strategy:
matrix:
os:
- macos-latest
- ubuntu-latest
node:
- 20

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

name: Build on ${{ matrix.os }} with Node ${{ matrix.node }}

steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- uses: actions/checkout@v6

- name: Install pnpm
uses: pnpm/action-setup@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: "pnpm"

- name: Install dependencies
run: |
pnpm install
- name: Setup environment
uses: ./.github/actions/setup-env

- name: Build
run: |
Expand All @@ -45,14 +46,10 @@ jobs:
- macos-latest
- ubuntu-latest

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

name: Test on ${{ matrix.os }}

runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- uses: actions/checkout@v6

- name: Setup GitHub SSH
uses: ./
Expand All @@ -70,7 +67,7 @@ jobs:
OUTPUT_SSH_PATH: ${{ steps.github.outputs.ssh-path }}
OUTPUT_SSH_AGENT_PID: ${{ steps.github.outputs.ssh-agent-pid }}
OUTPUT_SSH_AUTH_SOCK: ${{ steps.github.outputs.ssh-auth-sock }}
run:
run: |
sh ./test/test.sh

- name: Setup GitLab SSH
Expand All @@ -94,5 +91,5 @@ jobs:
OUTPUT_SSH_PATH: ${{ steps.gitlab.outputs.ssh-path }}
OUTPUT_SSH_AGENT_PID: ${{ steps.gitlab.outputs.ssh-agent-pid }}
OUTPUT_SSH_AUTH_SOCK: ${{ steps.gitlab.outputs.ssh-auth-sock }}
run:
run: |
sh ./test/test.sh
4 changes: 4 additions & 0 deletions .oxfmtrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$schema": "./node_modules/oxfmt/configuration_schema.json",
"ignorePatterns": [".github", ".pnpm-store", "lib/**"]
}
4 changes: 4 additions & 0 deletions .oxlintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$schema": "./node_modules/oxlint/configuration_schema.json",
"ignorePatterns": [".github", ".pnpm-store", "lib/**"]
}
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ pnpm format
```

Run workflows with [act](https://github.com/nektos/act):

```
act pull_request
```
Expand Down
74 changes: 37 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ jobs:
name: Example
runs-on: ubuntu-latest
steps:
- name: Setup SSH
uses: MrSquaare/ssh-setup-action@v3
with:
host: github.com
private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Setup SSH
uses: MrSquaare/ssh-setup-action@v3
with:
host: github.com
private-key: ${{ secrets.SSH_PRIVATE_KEY }}
```

## Environment variables
Expand Down Expand Up @@ -70,13 +70,13 @@ jobs:
name: Clone
runs-on: ubuntu-latest
steps:
- name: Setup SSH
uses: MrSquaare/ssh-setup-action@v3
with:
host: github.com
private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Clone repository
run: git clone git@github.com:username/repository.git
- name: Setup SSH
uses: MrSquaare/ssh-setup-action@v3
with:
host: github.com
private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Clone repository
run: git clone git@github.com:username/repository.git
```

### Multiple keys and multiple clone
Expand All @@ -91,31 +91,31 @@ jobs:
name: Clone
runs-on: ubuntu-latest
steps:
- name: Setup GitHub SSH
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@v3
with:
host: gitlab.com
private-key: ${{ secrets.SSH_PRIVATE_KEY_GITLAB }}
private-key-name: gitlab
- name: Setup Server SSH with custom port
uses: MrSquaare/ssh-setup-action@v3
with:
host: 1.2.3.4
port: 8000
private-key: ${{ secrets.SSH_PRIVATE_KEY_GITLAB }}
private-key-name: server
- name: Clone GitHub repository
run: git clone git@github.com:username/repository.git
- name: Clone GitLab repository
run: git clone git@gitlab.com:username/repository.git
- name: SSH to server
run: ssh -p 8000 ubuntu@1.2.3.4 'echo Hello'
- name: Setup GitHub SSH
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@v3
with:
host: gitlab.com
private-key: ${{ secrets.SSH_PRIVATE_KEY_GITLAB }}
private-key-name: gitlab
- name: Setup Server SSH with custom port
uses: MrSquaare/ssh-setup-action@v3
with:
host: 1.2.3.4
port: 8000
private-key: ${{ secrets.SSH_PRIVATE_KEY_GITLAB }}
private-key-name: server
- name: Clone GitHub repository
run: git clone git@github.com:username/repository.git
- name: Clone GitLab repository
run: git clone git@gitlab.com:username/repository.git
- name: SSH to server
run: ssh -p 8000 ubuntu@1.2.3.4 'echo Hello'
```

## Contributing
Expand Down
10 changes: 0 additions & 10 deletions eslint.config.mjs

This file was deleted.

12 changes: 11 additions & 1 deletion lib/cleanup.js
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
"use strict";var o=require("child_process");try{console.log("Stopping SSH agent"),(0,o.execFileSync)("ssh-agent",["-k"],{stdio:"inherit"})}catch(e){console.log(e.message),console.log("Error stopping the SSH agent, proceeding anyway")}
import { execFileSync } from "child_process";
//#region src/cleanup.ts
try {
console.log("Stopping SSH agent");
execFileSync("ssh-agent", ["-k"], { stdio: "inherit" });
} catch (error) {
if (error instanceof Error) console.warn("Error stopping the SSH agent, proceeding anyway:", error.message);
console.warn("Error stopping the SSH agent, proceeding anyway");
}
//#endregion
export {};
15,081 changes: 15,078 additions & 3 deletions lib/index.js

Large diffs are not rendered by default.

50 changes: 23 additions & 27 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,44 +1,40 @@
{
"name": "ssh-setup-action",
"version": "3.1.1",
"version": "3.1.2",
"description": "Setup SSH",
"homepage": "https://github.com/MrSquaare/ssh-setup-action#readme",
"bugs": {
"url": "https://github.com/MrSquaare/ssh-setup-action/issues"
},
"license": "MIT",
"author": "MrSquaare",
"repository": {
"type": "git",
"url": "git+https://github.com/MrSquaare/ssh-setup-action.git"
},
"author": "MrSquaare",
"license": "MIT",
"bugs": {
"url": "https://github.com/MrSquaare/ssh-setup-action/issues"
},
"homepage": "https://github.com/MrSquaare/ssh-setup-action#readme",
"type": "module",
"main": "src/index.ts",
"scripts": {
"preinstall": "npx only-allow pnpm",
"build": "ncc build src/index.ts -o lib -m",
"lint": "eslint .",
"format": "eslint --fix .",
"build": "rolldown -c",
"check": "oxlint . && oxfmt --check .",
"check:fix": "oxlint . --fix && oxfmt --write .",
"test": "sh ./test/test.sh"
},
"devDependencies": {
"@eslint/js": "^9.33.0",
"@types/node": "^20.19.10",
"@vercel/ncc": "^0.38.3",
"eslint": "^9.33.0",
"eslint-config-prettier": "^10.1.8",
"eslint-plugin-prettier": "^5.5.4",
"prettier": "^3.6.2",
"typescript": "^5.9.2",
"typescript-eslint": "^8.39.1"
},
"dependencies": {
"@actions/core": "^1.11.1",
"@actions/exec": "^1.1.1",
"nanoid": "^5.1.5",
"@actions/core": "^3.0.0",
"@actions/exec": "^3.0.0",
"nanoid": "^5.1.6",
"valid-filename": "^4.0.0"
},
"devDependencies": {
"@types/node": "^20.19.37",
"oxfmt": "^0.36.0",
"oxlint": "^1.51.0",
"rolldown": "1.0.0-rc.7",
"typescript": "^5.9.3"
},
"engines": {
"node": ">=20"
},
"packageManager": "pnpm@10.14.0"
}
"packageManager": "pnpm@10.30.3"
}
Loading