@@ -28,6 +28,7 @@ disk_size=
28
28
image_project=
29
29
image=
30
30
image_family=
31
+ label=
31
32
scopes=
32
33
shutdown_timeout=
33
34
task=
@@ -44,6 +45,7 @@ while getopts_long :h opt \
44
45
image_project optional_argument \
45
46
image optional_argument \
46
47
image_family optional_argument \
48
+ label optional_argument \
47
49
scopes required_argument \
48
50
shutdown_timeout required_argument \
49
51
task required_argument \
@@ -79,6 +81,9 @@ while getopts_long :h opt \
79
81
image_family)
80
82
image_family=${OPTLARG-$image_family }
81
83
;;
84
+ label)
85
+ label=${OPTLARG-$label }
86
+ ;;
82
87
scopes)
83
88
scopes=$OPTLARG
84
89
;;
@@ -102,6 +107,10 @@ done
102
107
103
108
function start_vm {
104
109
VM_ID=" runner-$( echo ${GITHUB_RUN_ID} -${GITHUB_RUN_NUMBER} -${task} | sha1sum | cut -f 1 -d " " ) "
110
+ if [ ! -z " ${label} " ]; then
111
+ echo " Label provided, using it as VM ID (${label} )"
112
+ VM_ID=" ${label} "
113
+ fi
105
114
106
115
if [ ! -z " $( gcloud compute instances list | grep " ${VM_ID} " ) " ]; then
107
116
# the VM already exists.
@@ -114,7 +123,7 @@ function start_vm {
114
123
fi
115
124
116
125
echo " Starting GCE VM ..."
117
- if [ -z " $runner_token " ]; then
126
+ if [ -z " $runner_token " ]; then
118
127
echo " ❌ runner_token parameter is required"
119
128
exit 1
120
129
fi
@@ -123,7 +132,7 @@ function start_vm {
123
132
-H " Authorization: Bearer $runner_token " \
124
133
" https://api.github.com/repos/$GITHUB_REPOSITORY /actions/runners/registration-token" |
125
134
jq -r .token)
126
- if [ -z " $RUNNER_TOKEN " ]; then
135
+ if [ -z " $RUNNER_TOKEN " ]; then
127
136
echo " ❌ Failed to get a registration token"
128
137
exit 1
129
138
fi
@@ -202,10 +211,10 @@ REMOVE_TOKEN=\$(curl \
202
211
-H "Accept: application/vnd.github+json" \
203
212
-H "Authorization: Bearer ${RUNNER_TOKEN} " \
204
213
https://api.github.com/repos/${GITHUB_REPOSITORY} /actions/runners/remove-token | jq .token --raw-output)
205
- if [ -z "\$ REMOVE_TOKEN" ]; then
214
+ if [ -z "\$ REMOVE_TOKEN" ]; then
206
215
echo "❌ Failed to get a removal token"
207
216
exit 0
208
- fi
217
+ fi
209
218
210
219
su -s /bin/bash -c "cd /actions-runner/;/actions-runner-1/config.sh remove --token \$ {REMOVE_TOKEN}" runner
211
220
su -s /bin/bash -c "cd /actions-runner/;/actions-runner-2/config.sh remove --token \$ {REMOVE_TOKEN}" runner
0 commit comments