Skip to content

Commit dd57b76

Browse files
Copilotlachlangrose
andcommitted
Fix code review issues: safer dry-run defaults, branch validation, and loop handling
Co-authored-by: lachlangrose <7371904+lachlangrose@users.noreply.github.com>
1 parent d663446 commit dd57b76

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

.github/workflows/cleanup-lint-branches.yml

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ jobs:
4444
- name: Cleanup lint branches
4545
env:
4646
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
47-
DRY_RUN: ${{ github.event.inputs.dry_run || 'false' }}
47+
# Default to false for manual triggers with dry_run=false, otherwise true
48+
# This ensures scheduled runs default to true (safe mode)
49+
DRY_RUN: ${{ github.event.inputs.dry_run == 'false' && 'false' || 'true' }}
4850
BRANCH_AGE_DAYS: 7
4951
run: |
5052
set -e
@@ -76,13 +78,19 @@ jobs:
7678
echo "Found $(echo "$lint_branches" | wc -l) lint branches"
7779
echo ""
7880
79-
# Process each branch
80-
for branch in $lint_branches; do
81+
# Process each branch (using while read to handle special characters safely)
82+
while IFS= read -r branch; do
83+
[ -z "$branch" ] && continue
8184
total_branches=$((total_branches + 1))
8285
echo "🔍 Processing: $branch"
8386
84-
# Extract run ID from branch name (e.g., lint/style-fixes-17199517932)
85-
run_id=$(echo "$branch" | sed 's/lint\/style-fixes-//')
87+
# Validate branch name matches expected pattern
88+
if [[ ! "$branch" =~ ^lint/style-fixes-[0-9]+$ ]]; then
89+
echo " ⚠️ Warning: Branch name doesn't match expected pattern, skipping"
90+
skipped_branches=$((skipped_branches + 1))
91+
echo ""
92+
continue
93+
fi
8694
8795
# Check if there's a PR for this branch
8896
pr_number=$(gh pr list --state all --head "$branch" --json number --jq '.[0].number' 2>/dev/null || echo "")
@@ -151,7 +159,7 @@ jobs:
151159
fi
152160
153161
echo ""
154-
done
162+
done <<< "$lint_branches"
155163
156164
# Print summary
157165
echo "📊 Cleanup Summary"

0 commit comments

Comments
 (0)