File tree 2 files changed +20
-7
lines changed
2 files changed +20
-7
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ See [action.yml](./action.yml) for more detailed information.
13
13
* ` ssh-port ` - ssh port, default 22
14
14
* ` ssh-username ` - ssh username
15
15
* ` ssh-private-key ` - content of ssh private key. ex raw content of ~ /.ssh/id_rsa
16
+ * ` ssh-passphrase ` - passphrase for ssh private key. no default.
16
17
* ` ssh-socket ` - ssh socket, default /tmp/ssh-auth.sock
17
18
* ` context-name ` - name of docker context. default: remote
18
19
* ` context-use ` - indicate which this context is set as docker current context. default: false
32
33
ssh-host : ${{ secrets.SSH_HOST }}
33
34
ssh-username : ${{ secrets.SSH_USERNAME }}
34
35
ssh-private-key : ${{ secrets.SSH_PRIVATE_KEY }}
36
+ ssh-passphrase : ${{ secrets.SSH_PASSPHRASE }}
35
37
36
38
- name : Inspect docker context
37
39
run : docker context ls -q
Original file line number Diff line number Diff line change @@ -12,6 +12,9 @@ inputs:
12
12
ssh-private-key :
13
13
description : ' content of ssh private key. ex raw content of ~/.ssh/id_rsa'
14
14
required : true
15
+ ssh-passphrase :
16
+ description : ' passphrase for private key, optional'
17
+ required : false
15
18
ssh-port :
16
19
description : ' ssh port, default 22'
17
20
required : false
37
40
run : |
38
41
mkdir -p ~/.ssh
39
42
chmod 700 ~/.ssh
40
-
41
- - shell : bash
42
- name : Start the ssh agent
43
- run : |
44
- ssh-agent -a "${{ inputs.ssh-socket }}"
45
- export SSH_AUTH_SOCK="${{ inputs.ssh-socket }}"
46
43
47
44
- shell : bash
48
45
name : Add the private key
55
52
run : ssh-keyscan -p "${{ inputs.ssh-port }}" "${{ inputs.ssh-host }}" > ~/.ssh/known_hosts
56
53
57
54
- shell : bash
58
- name : Create the docker context
55
+ name : Create the docker context
59
56
run : docker context create ${{ inputs.context-name }} --docker "host=ssh://${{ inputs.ssh-username}}@${{ inputs.ssh-host }}:${{ inputs.ssh-port }}"
57
+
58
+ - shell : bash
59
+ name : Start the ssh agent and set the environment variables
60
+ run : |
61
+ ssh-agent -a "${{ inputs.ssh-port }}"
62
+ echo "SSH_AUTH_SOCK=${{ inputs.ssh-port}}" >> $GITHUB_ENV
63
+ echo "SSH_AGENT_PID=$SSH_AGENT_PID" >> $GITHUB_ENV
64
+
65
+ - shell : bash
66
+ # https://unix.stackexchange.com/a/571756/559668
67
+ name : Run ssh-add with passphrase
68
+ if : ${{ inputs.ssh-passphrase }}
69
+ run : |
70
+ { sleep 1; echo ${{ inputs.ssh-passphrase }}; } | script -q /dev/null -c 'ssh-add'
60
71
61
72
- shell : bash
62
73
name : Set the context as current context
You can’t perform that action at this time.
0 commit comments