2024-09-16 15:36:37 +02:00
|
|
|
#!/bin/bash
|
2024-09-26 13:45:49 +02:00
|
|
|
# waits for commits on any branch on origin, pulls and build it
|
2024-09-16 15:36:37 +02:00
|
|
|
|
2024-09-26 12:04:41 +02:00
|
|
|
# Configuration: Set the remote repository name and check interval
|
|
|
|
BUILD_CMD="gw-test" # Placeholder for the build command
|
|
|
|
|
|
|
|
# Fetch the latest updates from the origin
|
|
|
|
git fetch origin
|
|
|
|
|
|
|
|
# Keep track of local branches at the start
|
|
|
|
local_branches=$(git branch -r | sed 's/origin\///')
|
2024-09-16 15:36:37 +02:00
|
|
|
|
|
|
|
while true; do
|
2024-09-26 12:04:41 +02:00
|
|
|
echo "Checking for new branches..."
|
|
|
|
|
|
|
|
# Fetch the latest updates from the origin
|
|
|
|
git fetch origin
|
|
|
|
|
|
|
|
# List the remote branches after fetching and compare with local branches
|
|
|
|
new_branches=$(git branch -r | sed 's/origin\///' | grep -Fxv "$local_branches")
|
|
|
|
|
|
|
|
if [ -n "$new_branches" ]; then
|
|
|
|
for branch in $new_branches; do
|
|
|
|
echo "New branch detected: $branch"
|
2024-09-16 15:36:37 +02:00
|
|
|
|
2024-09-26 12:04:41 +02:00
|
|
|
# Check out the new branch locally
|
|
|
|
git checkout -b "$branch" "origin/$branch"
|
|
|
|
|
|
|
|
# Placeholder for build process (replace $BUILD_CMD with actual build steps)
|
|
|
|
echo "Building branch $branch..."
|
|
|
|
# eval "$BUILD_CMD"
|
|
|
|
|
|
|
|
# Update the local branch list
|
|
|
|
local_branches="$local_branches $branch"
|
|
|
|
done
|
|
|
|
else
|
|
|
|
echo "No new branches found."
|
|
|
|
fi
|
|
|
|
|
|
|
|
# wait 10s with a little animation
|
|
|
|
echo -e -n " waiting for changes (/) ..."
|
|
|
|
sleep 2
|
|
|
|
echo -e -n "\r\033[K waiting for changes (-) ..."
|
|
|
|
sleep 2
|
|
|
|
echo -e -n "\r\033[K waiting for changes (\) ..."
|
|
|
|
sleep 2
|
|
|
|
echo -e -n "\r\033[K waiting for changes (|) ..."
|
|
|
|
sleep 2
|
|
|
|
echo -e -n "\r\033[K waiting for changes ( ) ... "
|
|
|
|
sleep 2
|
|
|
|
echo -e -n "\r\033[K checking for changes"
|
2024-09-16 15:36:37 +02:00
|
|
|
done
|
2024-09-26 12:04:41 +02:00
|
|
|
|