-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaction.yml
80 lines (74 loc) · 2.53 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
name: 'Append BuildX nodes'
description: 'Appends docker buildx nodes to an already setup buildex builder.'
inputs:
builder:
description: "The builder name from the previous step"
default: ""
required: true
platform:
description: "For what platform to add the new node (defaults to `linux/arm64`)"
default: "linux/arm64"
required: false
node_name:
description: "The name of the new node (defaults to `arm`)"
default: "arm"
required: false
driver_opt:
description: "Some --driver-opt settings - i.e. `nodeselector=kubernetes.io/arch=arm64`"
default: ""
required: false
endpoint:
description: "An endpoint/context for this node - i.e. `ssh://[email protected]`"
default: ""
required: false
ssh_private_key:
description: "If the endpoint is a ssh:// endpoint, load this private key"
default: ""
required: false
runs:
using: "composite"
steps:
- env:
BUILDER_NAME: ${{ inputs.builder }}
NODE_PLATFORM: ${{ inputs.platform }}
NODE_NAME: ${{ inputs.node_name }}
DRIVER_OPT: ${{ inputs.driver_opt }}
ENDPOINT: ${{ inputs.endpoint }}
SSH_PRIVATE_KEY: ${{ inputs.ssh_private_key }}
shell: bash
id: composer_run
run: |
set -e
# Load ssh key allowing access to the remote docker
if [ ! -z "$SSH_PRIVATE_KEY" ]; then
# Do not check hostkey (for now)
mkdir -p ~/.ssh
cat <<EOF > ~/.ssh/config
Host *
StrictHostKeyChecking no
UserKnownHostsFile=/dev/null
ControlMaster auto
ControlPath ~/.ssh/control-%C
ControlPersist yes
EOF
eval $(ssh-agent -s)
ssh-add <(echo "$SSH_PRIVATE_KEY")
# Remember this agent also in future steps, because it will be used in the "build" step later on
echo "SSH_AUTH_SOCK=$SSH_AUTH_SOCK" >> $GITHUB_ENV
fi
if [ ! -z "$ENDPOINT" ]; then
echo "* Testing connection to $ENDPOINT..."
docker -H $ENDPOINT info
fi
# Append the node to the builder
BUILDX_OPTS=
if [ ! -z "$DRIVER_OPT" ]; then
BUILDX_OPTS=--driver-opt $DRIVER_OPT
fi
echo "* Appending buildx node $NODE_NAME to builder $BUILDER_NAME (for platform: $NODE_PLATFORM)..."
docker buildx create --append --name $BUILDER_NAME \
--node $NODE_NAME --platform $NODE_PLATFORM \
$BUILDX_OPTS $ENDPOINT
branding:
icon: 'package'
color: 'purple'