File tree Expand file tree Collapse file tree 6 files changed +3598
-0
lines changed
Expand file tree Collapse file tree 6 files changed +3598
-0
lines changed Original file line number Diff line number Diff line change 1+ node_modules /
Original file line number Diff line number Diff line change 1+ # SSH Socket Setup GitHub Action
2+ Setup an SSH socket with a private key.
3+
4+ ## Inputs
5+ ### ` host `
6+ ** Required** remote hostname
7+
8+ ### ` socket-path `
9+ ** Required** Path at which to create socket.
10+
11+ ### ` key `
12+ ** Required** SSH private key
13+
14+ ## Outputs
15+ ### ` socket-path `
16+ Path at which socket was created.
17+
18+ ## Example usage
19+ - name: SSH Socket Setup
20+ id: ssh-socket-action
21+ uses: ./.github/actions/ssh-sock-setup
22+ with:
23+ host: github.com
24+ socket-path: /tmp/ssh_agent.sock
25+ key: BASE64_SECRET_KEY
26+
27+ - name: Use SSH socket
28+ run: |
29+ ls -l "${{ steps.actiontest.outputs.socket-path }}"
Original file line number Diff line number Diff line change 1+ name : ' SSH Socket Setup'
2+ description : ' Setup an SSH socket with a private key'
3+ inputs :
4+ host :
5+ description : ' remote hostname'
6+ require : true
7+ socket-path :
8+ description : ' path at which to create socket'
9+ required : true
10+ key :
11+ description : ' ssh private key'
12+ required : true
13+ outputs :
14+ socket-path :
15+ description : ' path at which socket was created'
16+ runs :
17+ using : ' node12'
18+ main : ' index.js'
Original file line number Diff line number Diff line change 1+ const core = require ( '@actions/core' ) ;
2+ const github = require ( '@actions/github' ) ;
3+
4+ const { exec } = require ( 'child_process' ) ;
5+
6+ const host = core . getInput ( 'host' ) ;
7+ const socketPath = core . getInput ( 'socket-path' ) ;
8+ const key = core . getInput ( 'key' ) ;
9+
10+ console . log ( `Attempting to create ${ socketPath } ...` ) ;
11+ exec (
12+ 'mkdir ~/.ssh && ' +
13+ `ssh-keyscan "${ host } " >> ~/.ssh/known_hosts && ` +
14+ `ssh-agent -a "${ socketPath } " > /dev/null && ` +
15+ `echo "${ key } " | base64 -d | ssh-add - && ` +
16+ `ls -l "${ socketPath } "` ,
17+ { stdio : 'inherit' }
18+ ) ;
19+
20+ console . log ( `Created ${ socketPath } ` ) ;
21+ core . setOutput ( 'socket-path' , socketPath ) ;
22+
23+ console . log ( 'Done; exiting.' ) ;
You can’t perform that action at this time.
0 commit comments