-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
32 lines (31 loc) · 1.01 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
name: 'Inject SSH Key'
description: 'Configures CI environment to use the private SSH key from a given secret'
inputs:
private-key:
description: 'Private SSH key to configure'
required: true
host-name:
description: 'Hostname to configure in ~/.ssh/known_hosts, defaults to github.com'
required: false
default: 'github.com'
runs:
using: "composite"
steps:
- name: write-ssh-key
shell: bash
run: |
install -m 600 -D /dev/null ~/.ssh/id_rsa
echo "${{ inputs.private-key }}" > ~/.ssh/id_rsa
- name: add-to-know-hosts
shell: bash
run: |
install -m 600 -D /dev/null ~/.ssh/known_hosts
host='${{ inputs.host-name }}'
hosts="$(dig +short "$host" | grep -v '\.$' | sed -z 's|\n|,|g')$host"
echo "Adding keys for $hosts"
ssh-keyscan -H "$hosts" > ~/.ssh/known_hosts
(ssh-keygen -F "$host" > /dev/null && echo "$host registered") \
|| echo "Failed to register $host"
branding:
icon: 'log-in'
color: 'purple'