#!/bin/bash # Check if correct number of arguments are provided if [ "$#" -ne 2 ]; then echo "Usage: $0 " exit 1 fi repository_name="$1" branch_name=$(basename "$2") BRANCHES_FOLDER="/html/branches" PROGRAMM_REPOSITORY="git_programm:AG-Programm/parteiprogramm.git" # Echo parameters echo "Webhook recieved for repository: $repository_name and branch: $branch_name" # Check if the branch directory exists branch_dir="$BRANCHES_FOLDER/$(basename "$branch_name")" if [ -d "$branch_dir" ]; then echo "Directory $branch_dir exists, performing git pull..." # Change directory to branch directory cd "$branch_dir" # Perform git pull echo "Updating $branch_dir" git pull origin "$(basename "$branch_name")" else echo "Directory $branch_dir does not exist, cloning branch..." # Create branches directory if it doesn't exist mkdir -p branches # Clone the branch git clone --depth 1 --branch "$branch_name" --single-branch "$PROGRAMM_REPOSITORY" "$branch_dir" # reinitialize index.html ./generate_index_html.sh fi