implemented assets webhook
parent
d2e0165857
commit
12fecb0dc9
|
|
@ -1,2 +1,39 @@
|
|||
#!/bin/bash
|
||||
|
||||
#!/bin/bash
|
||||
|
||||
# Check if correct number of arguments are provided
|
||||
if [ "$#" -ne 2 ]; then
|
||||
echo "Usage: $0 <repository_name> <branch_name>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Echo parameters
|
||||
echo "Webhook recieved for repository: $repository_name and branch: $branch_name"
|
||||
|
||||
repository_name="$2"
|
||||
branch_name=$(basename "$1")
|
||||
|
||||
if [ "$branch_name" != "main" ]; then
|
||||
echo "Error: This hook must only update branch main, not $branch_name"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ASSETS_DIRECTORY="/html/branches/assets"
|
||||
ASSETS_REPOSITORY="git_assets:AG-IT/assets.git"
|
||||
|
||||
# Check if the assets directory exists
|
||||
if [ -d "$ASSETS_DIRECTORY" ]; then
|
||||
echo "Directory $ASSETS_DIRECTORY exists, performing git pull..."
|
||||
# Change directory to branch directory
|
||||
cd "$ASSETS_DIRECTORY"
|
||||
# Perform git pull
|
||||
echo "Updating $ASSETS_DIRECTORY"
|
||||
git pull origin main
|
||||
else
|
||||
echo "Directory $ASSETS_DIRECTORY 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 "$ASSETS_REPOSITORY" "$branch_dir"
|
||||
fi
|
||||
|
|
@ -16,7 +16,7 @@ PROGRAMM_REPOSITORY="git_programm:AG-Programm/parteiprogramm.git"
|
|||
echo "Webhook recieved for repository: $repository_name and branch: $branch_name"
|
||||
|
||||
# Check if the branch directory exists
|
||||
branch_dir="$BRANCES_FOLDER/$(basename "$branch_name")"
|
||||
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
|
||||
|
|
|
|||
Loading…
Reference in New Issue