#!/bin/bash

source .env

USERS_LIST=$(curl -s --header "Authorization: Bearer $GITLAB_TOKEN" "${GITLAB_SERVER}/users?per_page=100" | jq -r '.[] | select( .state == "deactivated" and .is_admin == false).id')

echo $USERS_LIST

for user in ${USERS_LIST[@]}; do
	echo "delete user_id: $user"
	curl -s --request DELETE --header "Authorization: Bearer $GITLAB_TOKEN" "${GITLAB_SERVER}/users/$user"
done
