Skip to content

Commit 66e91ab

Browse files
shyamjesalustiugov
authored andcommitted
start_runners.sh refactor
Signed-off-by: Shyam Jesal <[email protected]>
1 parent a34efbb commit 66e91ab

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

scripts/github_runner/start_runners.sh

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ if [ -z $1 ] || [ -z $2 ] || [ -z $3 ] || [ -z $4 ]; then
2828
exit -1
2929
fi
3030

31+
NUM_OF_RUNNERS=$1
32+
RUNNER_LABEL=$4
33+
RESTART_FLAG=$5
34+
3135
# fetch runner token using access token
3236
ACCESS_TOKEN=$3
3337
API_VERSION=v3
@@ -50,21 +54,21 @@ docker pull vhiveease/cri_test_runner
5054

5155

5256

53-
case "$4" in
57+
case "$RUNNER_LABEL" in
5458
"integ")
5559

56-
if [ "$5" == "restart" ]; then
60+
if [ "$RESTART_FLAG" == "restart" ]; then
5761
docker container stop $(docker ps --format "{{.Names}}" | grep integration_test-github_runner)
5862
docker container rm $(docker ps -a --format "{{.Names}}" | grep integration_test-github_runner)
5963
fi
60-
for number in $(seq 1 $1)
64+
for number in $(seq 1 $NUM_OF_RUNNERS)
6165
do
6266
# create access token as mentioned here (https://github.com/myoung34/docker-github-actions-runner#create-github-personal-access-token)
6367
CONTAINERID=$(docker run -d --restart always --privileged \
6468
--name "integration_test-github_runner-${HOSTNAME}-${number}" \
6569
-e REPO_URL="${_SHORT_URL}" \
6670
-e ACCESS_TOKEN="${ACCESS_TOKEN}" \
67-
-e LABELS="${3}" \
71+
-e LABELS="${RUNNER_LABEL}" \
6872
--ipc=host \
6973
-v /var/run/docker.sock:/var/run/docker.sock \
7074
--volume /dev:/dev \
@@ -74,10 +78,10 @@ case "$4" in
7478
;;
7579
"cri")
7680

77-
if [ "$5" == "restart" ]; then
81+
if [ "$RESTART_FLAG" == "restart" ]; then
7882
kind get clusters | while read line ; do kind delete cluster --name "$line" ; done
7983
fi
80-
for number in $(seq 1 $1)
84+
for number in $(seq 1 $NUM_OF_RUNNERS)
8185
do
8286
kind create cluster --image vhiveease/cri_test_runner --name "cri-test-github-runner-${HOSTNAME}-${number}"
8387
sleep 2m

0 commit comments

Comments
 (0)