104 lines
2.6 KiB
Bash
104 lines
2.6 KiB
Bash
#!/bin/bash
|
|
|
|
# Branch to process (test, preprod, master)
|
|
BRANCH=$1
|
|
|
|
# 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"
|
|
"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"
|
|
"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"
|
|
)
|
|
|
|
# Loop through each branch
|
|
for branch in "${branches[@]}"; do
|
|
prefix="${branch%%_*}"
|
|
|
|
# Check if the branch matches the input and the prefix is valid
|
|
if [ "$BRANCH" == "${branch_dirs[$prefix]}" ]; then
|
|
folder_name="${branch#*_}"
|
|
full_path="$BRANCH/$folder_name"
|
|
|
|
# Create the directory if it doesn't exist
|
|
mkdir -p "$full_path"
|
|
|
|
# Navigate to the directory
|
|
cd "$full_path" || { echo "Failed to access $full_path"; exit 1; }
|
|
|
|
# Pull the latest changes
|
|
git pull origin "$branch"
|
|
|
|
# Check if the pull was successful
|
|
if [ $? -eq 0 ]; then
|
|
echo "Successfully pulled $branch into $full_path"
|
|
else
|
|
echo "Failed to pull $branch"
|
|
exit 1
|
|
fi
|
|
|
|
# Return to the previous directory
|
|
cd - > /dev/null
|
|
fi
|
|
done
|