File tree Expand file tree Collapse file tree 3 files changed +47
-9
lines changed
Expand file tree Collapse file tree 3 files changed +47
-9
lines changed Original file line number Diff line number Diff line change 44 single_key_demo :
55 strategy :
66 matrix :
7- os : [ubuntu-latest, macOS-latest]
7+ os : [ubuntu-latest, macOS-latest, windows-latest ]
88 runs-on : ${{ matrix.os }}
99 steps :
1010 - uses : actions/checkout@v1
2626 uses : ./
2727 with :
2828 ssh-private-key : ${{ secrets.DEMO_KEY }}
29+
30+ docker_demo :
31+ runs-on : ubuntu-latest
32+ container :
33+ image : ubuntu:latest
34+ steps :
35+ - uses : actions/checkout@v1
36+ - run : apt update && apt install -y openssh-client
37+ - name : Setup key
38+ uses : ./
39+ with :
40+ ssh-private-key : |
41+ ${{ secrets.DEMO_KEY }}
42+ ${{ secrets.DEMO_KEY_2 }}
Original file line number Diff line number Diff line change @@ -118,12 +118,9 @@ exports.issueCommand = issueCommand;
118118const core = __webpack_require__ ( 470 ) ;
119119const child_process = __webpack_require__ ( 129 ) ;
120120const fs = __webpack_require__ ( 747 ) ;
121+ const os = __webpack_require__ ( 87 ) ;
121122
122123try {
123-
124- const home = process . env [ 'HOME' ] ;
125- const homeSsh = home + '/.ssh' ;
126-
127124 const privateKey = core . getInput ( 'ssh-private-key' ) ;
128125
129126 if ( ! privateKey ) {
@@ -132,6 +129,21 @@ try {
132129 return ;
133130 }
134131
132+ var home ;
133+
134+ if ( process . env [ 'OS' ] == 'Windows_NT' ) {
135+ console . log ( 'Preparing ssh-agent service on Windows' ) ;
136+ child_process . execSync ( 'sc config ssh-agent start=demand' , { stdio : 'inherit' } ) ;
137+
138+ home = os . homedir ( ) ;
139+ } else {
140+ // Use getent() system call, since this is what ssh does; makes a difference in Docker-based
141+ // Action runs, where $HOME is different from the pwent
142+ var { homedir : home } = os . userInfo ( ) ;
143+ }
144+
145+ const homeSsh = home + '/.ssh' ;
146+
135147 console . log ( `Adding GitHub.com keys to ${ homeSsh } /known_hosts` ) ;
136148 fs . mkdirSync ( homeSsh , { recursive : true } ) ;
137149 fs . appendFileSync ( `${ homeSsh } /known_hosts` , '\ngithub.com ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==\n' ) ;
Original file line number Diff line number Diff line change 11const core = require ( '@actions/core' ) ;
22const child_process = require ( 'child_process' ) ;
33const fs = require ( 'fs' ) ;
4+ const os = require ( 'os' ) ;
45
56try {
6-
7- const home = process . env [ 'HOME' ] ;
8- const homeSsh = home + '/.ssh' ;
9-
107 const privateKey = core . getInput ( 'ssh-private-key' ) ;
118
129 if ( ! privateKey ) {
1512 return ;
1613 }
1714
15+ var home ;
16+
17+ if ( process . env [ 'OS' ] == 'Windows_NT' ) {
18+ console . log ( 'Preparing ssh-agent service on Windows' ) ;
19+ child_process . execSync ( 'sc config ssh-agent start=demand' , { stdio : 'inherit' } ) ;
20+
21+ home = os . homedir ( ) ;
22+ } else {
23+ // Use getent() system call, since this is what ssh does; makes a difference in Docker-based
24+ // Action runs, where $HOME is different from the pwent
25+ var { homedir : home } = os . userInfo ( ) ;
26+ }
27+
28+ const homeSsh = home + '/.ssh' ;
29+
1830 console . log ( `Adding GitHub.com keys to ${ homeSsh } /known_hosts` ) ;
1931 fs . mkdirSync ( homeSsh , { recursive : true } ) ;
2032 fs . appendFileSync ( `${ homeSsh } /known_hosts` , '\ngithub.com ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==\n' ) ;
You can’t perform that action at this time.
0 commit comments