Skip to content
This repository was archived by the owner on Feb 15, 2026. It is now read-only.

Commit b8162ec

Browse files
committed
fix(ci): resolve double -e flag in cleanup workflow
CHANGES - Add explicit shell directive to avoid GitHub Actions default -e flag - Enhance script error handling with temp file approach - Improve percentage calculation safety with fallbacks IMPACT - Prevents exit code 1 failures in documentation cleanup step - Enables workflow to complete successfully in CI environment TECHNICAL NOTES - Removes conflict between GitHub Actions bash -e and script's -euo pipefail - Script maintains robust error handling while workflow uses plain bash
1 parent 5af55f7 commit b8162ec

2 files changed

Lines changed: 36 additions & 17 deletions

File tree

.github/workflows/auto-update-docs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ jobs:
6363
6464
- name: Clean non-documentation files
6565
run: ./scripts/clean-assets.sh
66+
shell: bash {0} # Avoid double -e flag since script already has -euo pipefail
6667

6768
- name: Pull latest changes by previous update-docs job
6869
run: git pull origin main

scripts/clean-assets.sh

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -129,27 +129,45 @@ clean_directory() {
129129
log_info "Cleaning $dir_name: $target_dir"
130130

131131
# Count files before cleanup
132-
local total_before
133-
total_before=$(find "$target_dir" -type f 2>/dev/null | wc -l | tr -d ' ') || total_before=0
132+
local total_before=0
133+
if total_before=$(find "$target_dir" -type f 2>/dev/null | wc -l | tr -d ' ' 2>/dev/null); then
134+
total_before=${total_before:-0}
135+
else
136+
total_before=0
137+
log_warning "Could not count files in $target_dir, proceeding with cleanup"
138+
fi
134139

135140
# Find and remove non-documentation files using configurable include/exclude lists
136141
local removed_count=0
137142

138-
# Use find with modular file checking
139-
while IFS= read -r -d '' file; do
140-
# Use modular function to check if file should be kept
141-
if should_keep_file "$file"; then
142-
continue # Keep this file
143-
fi
144-
145-
# Remove the file
146-
if rm -f "$file" 2>/dev/null; then
147-
((removed_count++))
148-
log_info "Removed: ${file#"$target_dir"/}"
149-
else
150-
log_warning "Failed to remove: ${file#"$target_dir"/}"
151-
fi
152-
done < <(find "$target_dir" -type f -print0 2>/dev/null)
143+
# Get list of all files first, then process them
144+
local temp_file_list
145+
temp_file_list=$(mktemp) || temp_file_list="/tmp/clean_assets_$$"
146+
147+
if find "$target_dir" -type f > "$temp_file_list" 2>/dev/null; then
148+
while IFS= read -r file; do
149+
# Skip empty lines
150+
[[ -n "$file" ]] || continue
151+
152+
# Use modular function to check if file should be kept
153+
if should_keep_file "$file"; then
154+
continue # Keep this file
155+
fi
156+
157+
# Remove the file
158+
if rm -f "$file" 2>/dev/null; then
159+
((removed_count++))
160+
log_info "Removed: ${file#"$target_dir"/}"
161+
else
162+
log_warning "Failed to remove: ${file#"$target_dir"/}"
163+
fi
164+
done < "$temp_file_list"
165+
else
166+
log_warning "Could not list files in $target_dir, skipping cleanup"
167+
fi
168+
169+
# Clean up temp file
170+
rm -f "$temp_file_list" 2>/dev/null || true
153171

154172
# Remove empty directories (but keep the main structure)
155173
find "$target_dir" -type d -empty -not -path "$target_dir" -delete 2>/dev/null || true

0 commit comments

Comments
 (0)