31 lines
702 B
Bash
31 lines
702 B
Bash
#!/bin/bash
|
|
|
|
# Load config file
|
|
source ./config.env
|
|
|
|
#set branch Name
|
|
BRANCH_NAME=$API_BRANCH_NAME
|
|
|
|
# Repository URL
|
|
REPO_URL="https://git.marcoaiot.com/admin/marco.pms.api.git"
|
|
REPO_DIR="marco.pms.api"
|
|
|
|
# Step 1: Clone the GitHub repository (use the branch defined)
|
|
if [ -d "$REPO_DIR" ]; then
|
|
echo "Repository already exists. Pulling latest changes from branch $BRANCH_NAME..."
|
|
cd "$REPO_DIR" || exist 1
|
|
|
|
# ensure we are on correct branch
|
|
git fetch origin
|
|
git checkout "$BRANCH_NAME"
|
|
git pull origin "$BRANCH_NAME"
|
|
|
|
else
|
|
echo "Cloning the Git repository from branch $BRANCH_NAME..."
|
|
git clone -b "$BRANCH_NAME" "$REPO_URL"
|
|
cd "$REPO_DIR" || exit 1
|
|
|
|
fi
|
|
|
|
echo "Successfully pull $BRANCH_NAME"
|