Skip to content

Commit 08f7740

Browse files
committed
test deploy-2
1 parent 59dfbae commit 08f7740

4 files changed

Lines changed: 13 additions & 48 deletions

File tree

.github/scripts/clasp_push.sh

Lines changed: 10 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -9,76 +9,54 @@ export LANG=C.UTF-8
99
function contains_changes() {
1010
local dir="$1"
1111
shift
12-
echo "Checking for changed files in $dir: $@"
13-
[[ "$*" == "" ]] && { echo "No changed files provided, skipping $dir"; return 1; }
14-
dir_absolute=$(realpath "$dir" 2>/dev/null || echo "$dir")
15-
dir_absolute="${dir_absolute%/}/"
12+
[[ "$*" == "" ]] && return 1
13+
dir_absolute=$(realpath "$dir" 2>/dev/null || pwd)
14+
dir_absolute="${dir_absolute%/}/" # Ensure trailing slash for pattern match
1615
for f in "$@"; do
17-
file_absolute=$(realpath "$f" 2>/dev/null || echo "$(pwd)/$f")
18-
echo "Comparing $file_absolute against $dir_absolute"
16+
file_absolute=$(realpath "$f" 2>/dev/null || echo "$f")
1917
if [[ "$file_absolute" == "$dir_absolute"* ]]; then
20-
echo "Found changed file $f in $dir"
2118
return 0
2219
fi
2320
done
24-
echo "No changed files in $dir"
2521
return 1
2622
}
2723

2824
# Ensure working directory is the repository root
29-
echo "Initial working directory: $(pwd)"
30-
cd "$GITHUB_WORKSPACE" || { echo "Failed to set working directory to $GITHUB_WORKSPACE"; exit 1; }
31-
echo "Current working directory: $(pwd)"
25+
cd "$GITHUB_WORKSPACE" || exit 1
3226

33-
# Debug input
34-
echo "Input changed files: $@"
27+
# If no input files, exit
3528
if [ $# -eq 0 ]; then
36-
echo "No input files provided, exiting"
3729
exit 0
3830
fi
3931

4032
# Filter changed files to only include src/ directories
41-
changed_files=""
42-
if [ $# -gt 0 ]; then
43-
changed_files=$(echo "$@" | xargs -n1 | grep '^src/' | xargs -n1 realpath 2>/dev/null | xargs -I {} dirname {} | sort -u || true)
44-
fi
45-
echo "Changed directories (filtered to src/): $changed_files"
33+
changed_files=$(echo "$@" | xargs -n1 | grep '^src/' | xargs -n1 realpath 2>/dev/null | xargs -I {} dirname {} | sort -u || true)
4634

4735
# Find all directories containing .clasp.json files
4836
dirs=()
49-
if ! find_output=$(find . -name '.clasp.json' -exec dirname {} \; | sort -u | xargs realpath 2>/dev/null); then
50-
echo "Warning: find command failed or no .clasp.json files found"
51-
else
37+
if find_output=$(find . -name '.clasp.json' -exec dirname {} \; | sort -u | xargs realpath 2>/dev/null); then
5238
IFS=$'\n' read -r -d '' -a dirs <<< "$find_output" || true
5339
fi
54-
echo "Clasp project directories: ${dirs[@]}"
5540

5641
exit_code=0
5742

5843
# Process each Clasp project directory
5944
for dir in "${dirs[@]}"; do
60-
echo "Processing directory: $dir"
6145
if [ ! -d "$dir" ]; then
62-
echo "Directory $dir does not exist, skipping"
6346
continue
6447
fi
65-
pushd "$dir" > /dev/null || { echo "Failed to enter $dir"; exit_code=1; continue; }
48+
pushd "$dir" > /dev/null || { exit_code=1; continue; }
49+
# Skip if the directory does not contain any changed files
6650
if ! contains_changes "$dir" "$@"; then
6751
popd > /dev/null
6852
continue
6953
fi
70-
echo "Publishing $dir"
7154
clasp push -f
7255
status=$?
7356
if [ $status -ne 0 ]; then
74-
echo "clasp push failed in $dir with status $status"
7557
exit_code=$status
7658
fi
7759
popd > /dev/null
7860
done
7961

80-
if [ $exit_code -ne 0 ]; then
81-
echo "Script push failed."
82-
fi
83-
8462
exit $exit_code

.github/workflows/deploy.yml

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,6 @@ jobs:
1616
uses: actions/checkout@v4
1717
with:
1818
ref: main # Ensure the correct branch is checked out
19-
fetch-depth: 0 # Fetch full history to enable git diff
20-
21-
- name: Get changed files
22-
id: changed-files
23-
run: |
24-
if [[ "${{ github.event_name }}" == "push" ]]; then
25-
CHANGED_FILES=$(git diff --name-only HEAD~1 | tr '\n' ' ' || true)
26-
else
27-
CHANGED_FILES=$(git diff --name-only origin/main | tr '\n' ' ' || true)
28-
fi
29-
echo "all_changed_files=$CHANGED_FILES" >> $GITHUB_OUTPUT
30-
31-
- name: Debug changed files
32-
run: |
33-
echo "Changed files: ${{ steps.changed-files.outputs.all_changed_files }}"
3419

3520
- name: Set up Node.js
3621
uses: actions/setup-node@v4
@@ -77,7 +62,7 @@ jobs:
7762
- name: Make clasp_push.sh executable
7863
run: chmod +x ./.github/scripts/clasp_push.sh
7964

80-
- name: Debug clasp_push.sh input
65+
- name: Check clasp_push.sh input
8166
run: |
8267
echo "Running clasp_push.sh with args: ${{ steps.changed-files.outputs.all_changed_files }}"
8368

src/ClaspTestScript/Code.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ function Run() {
1616
Logger.log("9/25-5");
1717
Logger.log("9/25-6");
1818
Logger.log("9/25-7");
19+
Logger.log("9/25-8");
1920
}

src/dummyscript/Code.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ function myFunction() {
1010
Logger.log("9/25-5");
1111
Logger.log("9/25-6");
1212
Logger.log("9/25-7");
13+
Logger.log("9/25-8");
1314
}

0 commit comments

Comments
 (0)