1+ #! /bin/bash
2+
3+ set -e # Exit on any error
14
25export LC_ALL=C.UTF-8
36export LANG=C.UTF-8
@@ -6,11 +9,13 @@ export LANG=C.UTF-8
69function contains_changes() {
710 local dir=" $1 "
811 shift
12+ echo " Checking for changed files in $dir : $@ "
913 [[ " $* " == " " ]] && { echo " No changed files provided, skipping $dir " ; return 1; }
10- dir_absolute=$( realpath " $dir " 2> /dev/null || echo " $dir " )
14+ dir_absolute=$( realpath " $dir " 2> /dev/null || pwd )
1115 for f in " $@ " ; do
1216 file_absolute=$( realpath " $f " 2> /dev/null || echo " $f " )
13- if [[" $file_absolute " == " $dir_absolute " /* ]]; then
17+ echo " Comparing $file_absolute against $dir_absolute "
18+ if [[ " $file_absolute " == " $dir_absolute " /* ]]; then
1419 echo " Found changed file $f in $dir "
1520 return 0
1621 fi
@@ -20,30 +25,31 @@ function contains_changes() {
2025}
2126
2227# Ensure working directory is the repository root
28+ echo " Initial working directory: $( pwd) "
2329cd " $GITHUB_WORKSPACE " || { echo " Failed to set working directory to $GITHUB_WORKSPACE " ; exit 1; }
30+ echo " Current working directory: $( pwd) "
2431
2532# Debug input
2633echo " Input changed files: $@ "
27- echo " Current working directory: $( pwd) "
34+ if [ $# -eq 0 ]; then
35+ echo " No input files provided, exiting"
36+ exit 0
37+ fi
2838
2939# Convert changed files to unique directories
30- changed_files=" "
31- if [ $# -gt 0 ]; then
32- changed_files=$( echo " $@ " | xargs -n1 realpath 2> /dev/null | xargs -I {} dirname {} | sort -u)
33- fi
40+ changed_files=$( echo " $@ " | xargs -n1 realpath 2> /dev/null | xargs -I {} dirname {} | sort -u || true)
3441echo " Changed directories: $changed_files "
3542
3643# Find all directories containing .clasp.json files
37- IFS=$' \n ' read -r -d ' ' -a dirs < <( find . -name ' .clasp.json' -exec dirname {} \; | sort -u | xargs realpath 2> /dev/null)
44+ IFS=$' \n ' read -r -d ' ' -a dirs < <( find . -name ' .clasp.json' -exec dirname {} \; | sort -u | xargs realpath 2> /dev/null || true )
3845echo " Clasp project directories: ${dirs[@]} "
3946
4047exit_code=0
4148
4249# Process each Clasp project directory
4350for dir in " ${dirs[@]} " ; do
51+ echo " Processing directory: $dir "
4452 pushd " $dir " > /dev/null || { echo " Failed to enter $dir " ; exit 1; }
45- echo " Checking directory: $dir "
46- # Skip if the directory does not contain any changed files
4753 if ! contains_changes " $dir " " $@ " ; then
4854 popd > /dev/null
4955 continue
0 commit comments