Skip to content

Commit dddc60b

Browse files
authored
Merge pull request #113 from hackforla/deploy_patch
debug clasp_push
2 parents 327124f + 01cdffa commit dddc60b

4 files changed

Lines changed: 22 additions & 10 deletions

File tree

.github/scripts/clasp_push.sh

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#!/bin/bash
2+
3+
set -e # Exit on any error
14

25
export LC_ALL=C.UTF-8
36
export LANG=C.UTF-8
@@ -6,11 +9,13 @@ export LANG=C.UTF-8
69
function 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)"
2329
cd "$GITHUB_WORKSPACE" || { echo "Failed to set working directory to $GITHUB_WORKSPACE"; exit 1; }
30+
echo "Current working directory: $(pwd)"
2431

2532
# Debug input
2633
echo "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)
3441
echo "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)
3845
echo "Clasp project directories: ${dirs[@]}"
3946

4047
exit_code=0
4148

4249
# Process each Clasp project directory
4350
for 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

.github/workflows/deploy.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ jobs:
7777
- name: Make clasp_push.sh executable
7878
run: chmod +x ./.github/scripts/clasp_push.sh
7979

80+
- name: Debug clasp_push.sh input
81+
run: |
82+
echo "Running clasp_push.sh with args: ${{ steps.changed-files.outputs.all_changed_files }}"
83+
8084
- name: Run clasp_push.sh
8185
run: |
8286
./.github/scripts/clasp_push.sh ${{ steps.changed-files.outputs.all_changed_files }}

src/ClaspTestScript/Code.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ function Run() {
1212
Logger.log("9/25-1");
1313
Logger.log("9/25-2");
1414
Logger.log("9/25-3");
15+
Logger.log("9/25-4");
1516
}

src/dummyscript/Code.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ function myFunction() {
66
Logger.log("9/25-1");
77
Logger.log("9/25-2");
88
Logger.log("9/25-3");
9+
Logger.log("9/25-4");
910
}

0 commit comments

Comments
 (0)