File tree Expand file tree Collapse file tree 2 files changed +20
-7
lines changed Expand file tree Collapse file tree 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.
1313* ` ssh-port ` - ssh port, default 22
1414* ` ssh-username ` - ssh username
1515* ` 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.
1617* ` ssh-socket ` - ssh socket, default /tmp/ssh-auth.sock
1718* ` context-name ` - name of docker context. default: remote
1819* ` context-use ` - indicate which this context is set as docker current context. default: false
3233 ssh-host : ${{ secrets.SSH_HOST }}
3334 ssh-username : ${{ secrets.SSH_USERNAME }}
3435 ssh-private-key : ${{ secrets.SSH_PRIVATE_KEY }}
36+ ssh-passphrase : ${{ secrets.SSH_PASSPHRASE }}
3537
3638 - name : Inspect docker context
3739 run : docker context ls -q
Original file line number Diff line number Diff line change @@ -12,6 +12,9 @@ inputs:
1212 ssh-private-key :
1313 description : ' content of ssh private key. ex raw content of ~/.ssh/id_rsa'
1414 required : true
15+ ssh-passphrase :
16+ description : ' passphrase for private key, optional'
17+ required : false
1518 ssh-port :
1619 description : ' ssh port, default 22'
1720 required : false
3740 run : |
3841 mkdir -p ~/.ssh
3942 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 }}"
4643
4744 - shell : bash
4845 name : Add the private key
5552 run : ssh-keyscan -p "${{ inputs.ssh-port }}" "${{ inputs.ssh-host }}" > ~/.ssh/known_hosts
5653
5754 - shell : bash
58- name : Create the docker context
55+ name : Create the docker context
5956 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'
6071
6172 - shell : bash
6273 name : Set the context as current context
You can’t perform that action at this time.
0 commit comments