#!/bin/bash # Get list of changed files from git changed_files=$(git diff --cached --name-only) # Track if any demos were changed any_changes=false # Check each demo folder and rezip if changes detected # Get the git root directory root_dir=$(git rev-parse --show-toplevel) # Change to the demos directory relative to root cd "$root_dir/demos" for folder in *; do # Skip if this is a zip file if [[ "$folder" == *.zip ]]; then continue fi # Remove trailing slash and demos/ prefix folder=${folder#demos/} echo $folder # Check if any changed files are in this folder if echo "$changed_files" | grep -q "demos/$folder/*"; then echo "Changes detected in $folder, rezipping..." # Remove existing zip if it exists rm -f "$folder.zip" # Create new zip archive zip -r "$folder.zip" "$folder" # Stage the new zip file git add "$folder.zip" any_changes=true fi done if [ "$any_changes" = false ]; then echo "No demo folders were modified, skipping zip creation" exit 0 else echo "Demo folders were modified" exit 0 fi