#!/bin/bash # # Initialize dadi staging folder from repository # # - delete existing dadi staging folder # HTML_HOME="/html" BRANCHES_FOLDER="/html/branches" DADI_STAGING_REPOSITORY="git_dadi-staging:AG-IT/KlDaDiSeite.git" # # Remove all branch folders # for dir in "$BRANCHES_FOLDER"/*/; do dir_name=$(basename "$dir") echo "Deleting directory: $dir" rm -rf "$dir" done # # Fetch all branch names # branches=() while read -r ref; do # Extract branch name from the reference branch_name=$(echo "$ref" | awk '{print $2}' | sed 's/refs\/heads\///') # put into array branches+=("$branch_name") done < <(git ls-remote --heads "$DADI_STAGING_REPOSITORY") for branch in "${branches[@]}"; do echo "cloning $branch" git clone --depth 1 --branch "$branch" --single-branch "$DADI_STAGING_REPOSITORY" "$BRANCHES_FOLDER"/"$branch" done