|
44 | 44 | - name: Cleanup lint branches |
45 | 45 | env: |
46 | 46 | 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' }} |
48 | 50 | BRANCH_AGE_DAYS: 7 |
49 | 51 | run: | |
50 | 52 | set -e |
@@ -76,13 +78,19 @@ jobs: |
76 | 78 | echo "Found $(echo "$lint_branches" | wc -l) lint branches" |
77 | 79 | echo "" |
78 | 80 |
|
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 |
81 | 84 | total_branches=$((total_branches + 1)) |
82 | 85 | echo "🔍 Processing: $branch" |
83 | 86 |
|
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 |
86 | 94 |
|
87 | 95 | # Check if there's a PR for this branch |
88 | 96 | pr_number=$(gh pr list --state all --head "$branch" --json number --jq '.[0].number' 2>/dev/null || echo "") |
@@ -151,7 +159,7 @@ jobs: |
151 | 159 | fi |
152 | 160 |
|
153 | 161 | echo "" |
154 | | - done |
| 162 | + done <<< "$lint_branches" |
155 | 163 |
|
156 | 164 | # Print summary |
157 | 165 | echo "📊 Cleanup Summary" |
|
0 commit comments