#!/bin/bash # Git repository URL USERNAME=$1 TOKEN=$2 # Branch types and their corresponding directories declare -A branch_dirs=( ["dev"]="test" ["preprod"]="preprod" ["master"]="master" ) # List of branches branches=( "dev_odex-event" "dev_odex25_accounting" "dev_odex25_base" "dev_odex25_dms" "dev_odex25_fleet" "dev_odex25_helpdesk" "dev_odex25_hr" "dev_odex25_inventory" "dev_odex25_maintenance" "dev_odex25_mobile" "dev_odex25_pos" "dev_odex25_project" "dev_odex25_purchase" "dev_odex25_realstate" "dev_odex25_sales" "dev_odex25_survey" "dev_odex25_transactions" "dev_odex25_website" "dev_openeducat_erp-14.0.1.0" "dev_odex25_ensan" "dev_odex25_donation" "preprod_odex-event" "preprod_odex25_accounting" "preprod_odex25_base" "preprod_odex25_dms" "preprod_odex25_fleet" "preprod_odex25_helpdesk" "preprod_odex25_hr" "preprod_odex25_inventory" "preprod_odex25_maintenance" "preprod_odex25_mobile" "preprod_odex25_pos" "preprod_odex25_project" "preprod_odex25_purchase" "preprod_odex25_realstate" "preprod_odex25_sales" "preprod_odex25_survey" "preprod_odex25_transactions" "preprod_odex25_website" "preprod_openeducat_erp-14.0.1.0" "preprod_odex25_ensan" "preprod_odex25_donation" "master_odex-event" "master_odex25_accounting" "master_odex25_base" "master_odex25_dms" "master_odex25_fleet" "master_odex25_helpdesk" "master_odex25_hr" "master_odex25_inventory" "master_odex25_maintenance" "master_odex25_mobile" "master_odex25_pos" "master_odex25_project" "master_odex25_purchase" "master_odex25_realstate" "master_odex25_sales" "master_odex25_survey" "master_odex25_transactions" "master_odex25_website" "master_openeducat_erp-14.0.1.0" "master_odex25_ensan" "master_odex25_donation" ) # Loop through each branch for branch in "${branches[@]}"; do # Extract the prefix (dev, preprod, master) and the branch name prefix="${branch%%_*}" folder_name="${branch#*_}" # Determine the base directory based on the prefix base_dir="${branch_dirs[$prefix]}" # Full path for the folder inside the corresponding directory full_path="$base_dir/$folder_name" # Create the directory if it doesn't exist mkdir -p "$full_path" # Clone the specific branch into the designated folder using token-based authentication git clone --depth=1 -b "$branch" "https://$USERNAME:$TOKEN@github.com/expsa/odex25-standard-modules.git" "$full_path" # Check if the clone was successful if [ $? -eq 0 ]; then echo "Successfully cloned $branch into $full_path" else echo "Failed to clone $branch" exit 1 fi done