File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -106,14 +106,23 @@ while getopts_long :h opt \
106
106
done
107
107
108
108
function start_vm {
109
+ VM_ID=" gce-gh-runner-${GITHUB_RUN_ID} -${GITHUB_RUN_ATTEMPT} "
110
+
111
+ if [ ! -z " $( gcloud compute instances list | grep " ${VM_ID} " ) " ]; then
112
+ # the VM already exists.
113
+ # this can happen when we call the action from a reusable workflow.
114
+ # in these scenarios we don't want a new VM ;)
115
+ echo " Skipping creation of new VM. Using the existing one."
116
+ exit 0
117
+ fi
118
+
109
119
echo " Starting GCE VM ..."
110
120
RUNNER_TOKEN=$( curl -S -s -XPOST \
111
121
-H " authorization: Bearer ${token} " \
112
122
" https://api.github.com/repos/${GITHUB_REPOSITORY} /actions/runners/registration-token" |
113
123
jq -r .token)
114
124
echo " ✅ Successfully got the GitHub Runner registration token"
115
125
116
- VM_ID=" gce-gh-runner-${GITHUB_RUN_ID} -${GITHUB_RUN_ATTEMPT} "
117
126
image_project_flag=$( [[ -z " ${image_project} " ]] || echo " --image-project=${image_project} " )
118
127
image_flag=$( [[ -z " ${image} " ]] || echo " --image=${image} " )
119
128
image_family_flag=$( [[ -z " ${image_family} " ]] || echo " --image-family=${image_family} " )
You can’t perform that action at this time.
0 commit comments