programm-webhook/webhooks-git/assets-init.sh

38 lines
745 B
Bash

#!/bin/bash
#
# Initialize assets folder from repository
#
# - delete existing assets folder
# - fetch assets/main from repository
#
BRANCHES_FOLDER="/html/branches"
ASSETS_FOLDER="/html/branches/assets"
ASSETS_REPOSITORY="git_assets:AG-IT/assets.git"
ASSETS_BRANCH="main"
#
# Remove assets folder if exists
#
if [ -d "$ASSETS_FOLDER" ];
then
echo "Removing existing assets folder: $ASSETS_FOLDER"
rm -R "$ASSETS_FOLDER"
fi
#
# Create branches folder if not exist
#
if [ ! -d "$BRANCHES_FOLDER" ];
then
echo "Create branches folder: $BRANCES_FOLDER"
mkdir -p "$BRANCHES_FOLDER"
fi
#
# Clone assets folder from repository
#
git clone --depth 1 --branch "$ASSETS_BRANCH" --single-branch "$ASSETS_REPOSITORY" "$ASSETS_FOLDER"