You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Create the branch skip list that is a combination of the central workflow list and the branch skip list that can be populated in each individual repo.
$RunMonth = (Get-Date).AddMonths((Get-Date).Day -ge $DeleteOnDayOfMonth).ToString('MMMM') # If current day is greater or equal to $DeleteOnDayOfMonth, flip to next month ($True = 1). If not, stay on current month ($False = 0).
# Workflow will only delete branches on the date of the month specified by $DeleteOnDayOfMonth. On all other days the workflow runs, it will only generate
159
+
# Workflow will only delete branches on $DeletionDate. On all other days the workflow runs, it will only generate
128
160
# a report of what would have been deleted on that date.
129
-
If ($CurrentDay -eq $DeleteOnDayOfMonth) {
161
+
If ($CurrentDate.Date -eq $DeletionDate.Date) {
130
162
131
163
$DeletionRun = $True
132
164
@@ -167,13 +199,6 @@ jobs:
167
199
168
200
}
169
201
170
-
# Make sure $DeleteOnDayOfMonth is a valid month day. Not allowing above 28 so we don't have to deal with leap years or days with 30/31 days.
171
-
If (($DeleteOnDayOfMonth -notin 1..28)) {
172
-
173
-
Throw "ERROR: DeleteOnDayOfMonth must be between 1 and 28."
174
-
175
-
}
176
-
177
202
ForEach ($Page in $Branches) {
178
203
179
204
ForEach ($Branch in $Page) {
@@ -328,7 +353,7 @@ jobs:
328
353
# If the workflow is in reporting mode, don't delete the branch. If it isn't, delete it.
echo "## Deleted stale branches" >> $env:GITHUB_STEP_SUMMARY
479
+
If ($DeletionRun) {
480
+
481
+
echo "## Deleted stale branches" >> $env:GITHUB_STEP_SUMMARY
482
+
483
+
} Else {
484
+
485
+
echo "## Stale branches pending deletion" >> $env:GITHUB_STEP_SUMMARY
486
+
487
+
}
488
+
455
489
echo "" >> $env:GITHUB_STEP_SUMMARY
456
490
457
491
If ($DeleteBranchlistCount -gt 0) {
@@ -470,8 +504,10 @@ jobs:
470
504
471
505
} Else {
472
506
473
-
echo "The following branches will be deleted on **$RunMonth $DeleteOnDayOfMonth** because they are over $MaxDaysBehind days behind the $DefaultBranch branch and contain $MaxCommitsAhead or fewer commits not in the $DefaultBranch branch." >> $env:GITHUB_STEP_SUMMARY
474
-
echo "**If you don't want a branch to be deleted, merge $DefaultBranch into it before $RunMonth $DeleteOnDayOfMonth.**" >> $env:GITHUB_STEP_SUMMARY
507
+
echo "The following branches will be deleted on **$FriendlyDeletionDate** because they will be over $MaxDaysBehind days behind the $DefaultBranch branch on that date. They also contain $MaxCommitsAhead or fewer commits not in the $DefaultBranch branch." >> $env:GITHUB_STEP_SUMMARY
508
+
echo "" >> $env:GITHUB_STEP_SUMMARY
509
+
echo "> [!IMPORTANT]" >> $env:GITHUB_STEP_SUMMARY
510
+
echo "> **If you don't want a branch to be deleted, merge $DefaultBranch into it before $FriendlyDeletionDate.**" >> $env:GITHUB_STEP_SUMMARY
475
511
echo "" >> $env:GITHUB_STEP_SUMMARY
476
512
477
513
}
@@ -500,7 +536,7 @@ jobs:
500
536
501
537
} Else {
502
538
503
-
echo "No branches were deleted during this run." >> $env:GITHUB_STEP_SUMMARY
539
+
echo "No branches were deleted or were identified as pending deletion during this run." >> $env:GITHUB_STEP_SUMMARY
0 commit comments