source ./.env

message=""
index=0
runner_id=""

while [ $index -lt 3 ]
do

  if [ $index -lt 10 ]; then

    runner_id="00$index"

  elif [ $index -lt 100 ]; then

    runner_id="0$index"

  elif [ $index -lt 1000 ]; then

    runner_id="$index"

  fi

  echo "gitlab-runner-$runner_id configuration"

  for project_registration_token in "${RUNNER_REGISTRATION_TOKENS[@]}"
  do

    docker exec -it gitlab-runner-$runner_id \
        gitlab-runner register \
          --non-interactive \
          --url $GITLAB_IP_OR_DNS/ \
          --registration-token $project_registration_token \
          --description "gitlab-runner-$runner_id - docker images builder" \
          --executor "docker" \
          --docker-image ruby:latest
  
  done

  index=$((($index+1)))

done;