-
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathTaskfile.yml
More file actions
1512 lines (1318 loc) · 53.9 KB
/
Taskfile.yml
File metadata and controls
1512 lines (1318 loc) · 53.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# yaml-language-server: $schema=https://taskfile.dev/schema.json
# sous-chefs/meta — unified task runner
#
# NOTIFICATION MANAGEMENT
# task preview → dry run: show what cleanup-noise would dismiss (safe)
# task cleanup-noise → dismiss CI/bot noise, preserve sous-chefs Issues
# task check-sous-chefs → list unread sous-chefs Issues for review
# task list-all → all unread notifications
# task stats → notification counts by type / reason / org
# task mark-repo-read → mark one repo's notifications as read (REPO=owner/repo)
#
# ORG AUDIT & VISIBILITY
# task migration-status → release pipeline migration progress (FILTER= optional)
# task open-prs → all open PRs across the org (FILTER=, AUTHOR=, LABEL= optional)
# task ci-status → repos with failing CI on main (FILTER= optional)
# task label-sync → ensure required labels exist on all repos (DRY_RUN=true, FILTER= optional)
# task secrets-check → verify release pipeline secrets at org level
# task stale-repos → repos with no push in MONTHS=12 (FILTER= optional)
# task pending-releases → open release-please PRs waiting to be merged
#
# WORKFLOW & RELEASE PIPELINE
# task cancel-runs → cancel in-progress Actions runs (ORG=, REPO= optional)
# task update-release-pipeline → full 9-step release pipeline migration (REPO=)
# task create-workflow-branches → create workflow-overhaul branches (REPOS_PATH=)
# task create-workflow-prs → push branches and open PRs (REPOS_PATH=)
# task list-release-prs → open release PRs in browser (REPOS_PATH=, PATTERN=)
# task force-merge-prs → admin force-merge matching PRs (REPOS_PATH=, PATTERN=)
#
# BRANCH PROTECTION
# task branch-protection → update status checks on main (REPO=owner/repo)
#
# WEBHOOK MANAGEMENT
# task webhooks-check → show webhook status (REPOS='repo1 repo2')
# task webhooks-disable → disable active webhooks (REPOS='repo1 repo2')
version: "3"
vars:
ORG: sous-chefs
silent: false
tasks:
# ---------------------------------------------------------------------------
# default: Show available tasks when `task` is run with no arguments
# ---------------------------------------------------------------------------
default:
desc: "Show available tasks"
silent: true
cmds:
- task --list
# ---------------------------------------------------------------------------
# cleanup-noise: Dismiss high-volume CI/bot notification noise
#
# Dismisses notifications where:
# - Title contains "failed", "merged", or "closed" (case-insensitive)
# - OR reason code is "state_change"
# BUT preserves: sous-chefs org notifications of type "Issue"
# ---------------------------------------------------------------------------
cleanup-noise:
desc: "Prune CI/bot noise (failed/merged/closed/state_change) — preserves sous-chefs Issues"
silent: true
cmds:
- |
#!/usr/bin/env fish
set_color '#88C0D0'
echo ""
echo " GitHub Notification Cleanup"
echo " ══════════════════════════════════════════════════"
set_color normal
set_color '#EBCB8B'
echo " Fetching all unread notifications..."
set_color normal
set tmpfile (mktemp)
gh api /notifications --paginate --jq '.[]' | jq -s '.' > $tmpfile
# Single jq pass: compute total, dismiss IDs, and preserve count together
set parsed (jq -c '{
total: length,
dismiss_ids: [.[] | select(
((.subject.title | ascii_downcase | test("failed|merged|closed")) or
(.reason == "state_change"))
and not (.repository.owner.login == "sous-chefs" and .subject.type == "Issue")
) | .id],
preserve_count: ([.[] | select(
.repository.owner.login == "sous-chefs" and .subject.type == "Issue"
)] | length)
}' < $tmpfile)
rm $tmpfile
set total (echo $parsed | jq '.total')
set dismiss_ids (echo $parsed | jq -r '.dismiss_ids[]')
set preserve_count (echo $parsed | jq '.preserve_count')
set dismiss_count (count $dismiss_ids)
set_color '#88C0D0'
echo " Found $total unread notification(s) total"
set_color normal
if test $dismiss_count -eq 0
set_color '#A3BE8C'
echo " Nothing to dismiss — inbox is clean!"
set_color normal
exit 0
end
set_color '#EBCB8B'
echo " Dismissing $dismiss_count notification(s)..."
set_color normal
# Fire PATCH calls in batches of 10 concurrent requests
set marked 0
for id in $dismiss_ids
gh api --method PATCH /notifications/threads/$id > /dev/null &
set marked (math $marked + 1)
if test (math "$marked % 10") -eq 0
wait
echo " ... $marked / $dismiss_count dismissed"
end
end
wait
echo ""
set_color '#A3BE8C'
echo " ✔ Done"
echo " Dismissed : $dismiss_count"
echo " Preserved : $preserve_count (sous-chefs Issues — review with: task check-sous-chefs)"
set_color normal
echo ""
# ---------------------------------------------------------------------------
# check-sous-chefs: Surface active sous-chefs Issues for manual review
# ---------------------------------------------------------------------------
check-sous-chefs:
desc: "Show unread Issue notifications from sous-chefs/* repos for manual review"
silent: true
cmds:
- |
#!/usr/bin/env fish
set_color '#88C0D0'
echo ""
echo " Unread Issues — sous-chefs org"
echo " ══════════════════════════════════════════════════"
set_color normal
set tmpfile (mktemp)
gh api /notifications --paginate --jq '.[]' | jq -s '
[
.[] | select(
.repository.owner.login == "sous-chefs" and
.subject.type == "Issue"
)
] | sort_by(.repository.full_name)
' > $tmpfile
set count (jq 'length' < $tmpfile)
if test $count -eq 0
set_color '#A3BE8C'
echo " No unread sous-chefs Issues — you are all caught up!"
set_color normal
rm $tmpfile
echo ""
exit 0
end
echo ""
set_color '#EBCB8B'
printf " %-35s %-18s %-50s\n" "REPO" "REASON" "TITLE"
printf " %-35s %-18s %-50s\n" \
"-----------------------------------" \
"------------------" \
"--------------------------------------------------"
set_color normal
for row in (jq -r '.[] | [.repository.full_name, .reason, .subject.title, .subject.url] | @tsv' < $tmpfile)
set cols (string split \t -- $row)
set repo $cols[1]
set reason $cols[2]
set title $cols[3]
# Convert API URL to browser URL
set url (echo $cols[4] | sed 's|api\.github\.com/repos|github.com|' | sed 's|/issues/|/issues/|')
set_color '#88C0D0'
printf " %-35s " $repo
set_color '#BF616A'
printf "%-18s " $reason
set_color normal
printf "%-50s\n" $title
end
echo ""
set_color '#A3BE8C'
echo " Total: $count unread Issue(s) from sous-chefs"
set_color normal
echo ""
set_color '#EBCB8B'
echo " Browser links:"
set_color normal
for row in (jq -r '.[] | [.repository.full_name, .subject.url] | @tsv' < $tmpfile)
set cols (string split \t -- $row)
set repo $cols[1]
set url (echo $cols[2] | sed 's|api\.github\.com/repos|github.com|')
set_color '#88C0D0'
printf " %-35s " $repo
set_color normal
echo $url
end
rm $tmpfile
echo ""
# ---------------------------------------------------------------------------
# list-all: List all unread notifications with type, reason, and title
# ---------------------------------------------------------------------------
list-all:
desc: "List all unread notifications (repo, type, reason, title)"
silent: true
cmds:
- |
#!/usr/bin/env fish
set_color '#88C0D0'
echo ""
echo " All Unread Notifications"
echo " ══════════════════════════════════════════════════"
set_color normal
set tmpfile (mktemp)
gh api /notifications --paginate --jq '.[]' | jq -s 'sort_by(.repository.full_name)' > $tmpfile
set count (jq 'length' < $tmpfile)
if test $count -eq 0
set_color '#A3BE8C'
echo " Inbox zero — nothing to show."
set_color normal
rm $tmpfile
echo ""
exit 0
end
echo ""
set_color '#EBCB8B'
printf " %-40s %-15s %-18s %s\n" "REPO" "TYPE" "REASON" "TITLE"
printf " %-40s %-15s %-18s %s\n" \
"----------------------------------------" \
"---------------" \
"------------------" \
"-----"
set_color normal
for row in (jq -r '.[] | [.repository.full_name, .subject.type, .reason, .subject.title] | @tsv' < $tmpfile)
set cols (string split \t -- $row)
set_color '#88C0D0'
printf " %-40s " $cols[1]
set_color '#A3BE8C'
printf "%-15s " $cols[2]
set_color '#BF616A'
printf "%-18s " $cols[3]
set_color normal
printf "%s\n" $cols[4]
end
rm $tmpfile
echo ""
set_color '#88C0D0'
echo " Total: $count unread notification(s)"
set_color normal
echo ""
# ---------------------------------------------------------------------------
# stats: Show notification counts grouped by type, reason, and org
# ---------------------------------------------------------------------------
stats:
desc: "Show unread notification counts grouped by type, reason, and org"
silent: true
cmds:
- |
#!/usr/bin/env fish
set_color '#88C0D0'
echo ""
echo " Notification Statistics"
echo " ══════════════════════════════════════════════════"
set_color normal
set tmpfile (mktemp)
gh api /notifications --paginate --jq '.[]' | jq -s '.' > $tmpfile
set total (jq 'length' < $tmpfile)
set_color '#EBCB8B'
echo ""
echo " By Type:"
set_color normal
jq -r '
group_by(.subject.type) |
sort_by(-length) |
.[] |
" \(.[0].subject.type): \(length)"
' < $tmpfile
set_color '#EBCB8B'
echo ""
echo " By Reason:"
set_color normal
jq -r '
group_by(.reason) |
sort_by(-length) |
.[] |
" \(.[0].reason): \(length)"
' < $tmpfile
set_color '#EBCB8B'
echo ""
echo " By Org / Owner:"
set_color normal
jq -r '
group_by(.repository.owner.login) |
sort_by(-length) |
.[] |
" \(.[0].repository.owner.login): \(length)"
' < $tmpfile
set_color '#EBCB8B'
echo ""
echo " Noise estimate (would be dismissed by cleanup-noise):"
set_color normal
set noise (jq '
[
.[] | select(
(
(.subject.title | ascii_downcase | test("failed|merged|closed")) or
(.reason == "state_change")
) and not (
.repository.owner.login == "sous-chefs" and .subject.type == "Issue"
)
)
] | length
' < $tmpfile)
echo " $noise notification(s) would be dismissed"
echo " (run: task preview to see details)"
rm $tmpfile
echo ""
set_color '#A3BE8C'
echo " Total unread: $total"
set_color normal
echo ""
# ---------------------------------------------------------------------------
# preview: Dry run — show what cleanup-noise WOULD dismiss (no changes made)
# ---------------------------------------------------------------------------
preview:
desc: "Dry run of cleanup-noise — shows what would be dismissed without making any changes"
silent: true
cmds:
- |
#!/usr/bin/env fish
set_color '#EBCB8B'
echo ""
echo " [DRY RUN] cleanup-noise preview — no changes will be made"
echo " ══════════════════════════════════════════════════"
set_color normal
set tmpfile (mktemp)
set_color '#88C0D0'
echo " Fetching all unread notifications..."
set_color normal
gh api /notifications --paginate --jq '.[]' | jq -s '.' > $tmpfile
set to_dismiss (jq '
[
.[] | select(
(
(.subject.title | ascii_downcase | test("failed|merged|closed")) or
(.reason == "state_change")
) and not (
.repository.owner.login == "sous-chefs" and .subject.type == "Issue"
)
)
] | sort_by(.repository.full_name)
' < $tmpfile)
set to_preserve (jq '
[
.[] | select(
.repository.owner.login == "sous-chefs" and .subject.type == "Issue"
)
] | sort_by(.repository.full_name)
' < $tmpfile)
set dismiss_count (echo $to_dismiss | jq 'length')
set preserve_count (echo $to_preserve | jq 'length')
set_color '#BF616A'
echo ""
echo " Would DISMISS ($dismiss_count):"
set_color normal
echo $to_dismiss | jq -r '.[] | " [\(.reason)] \(.repository.full_name) — \(.subject.title)"'
set_color '#A3BE8C'
echo ""
echo " Would PRESERVE ($preserve_count — sous-chefs Issues):"
set_color normal
echo $to_preserve | jq -r '.[] | " [\(.reason)] \(.repository.full_name) — \(.subject.title)"'
rm $tmpfile
echo ""
set_color '#EBCB8B'
echo " Run 'task cleanup-noise' to apply these dismissals."
set_color normal
echo ""
# ---------------------------------------------------------------------------
# mark-repo-read: Mark all notifications for a specific repo as read
# Usage: task mark-repo-read REPO=owner/repo
# ---------------------------------------------------------------------------
mark-repo-read:
desc: "Mark all unread notifications for REPO=owner/repo as read (e.g. task mark-repo-read REPO=sous-chefs/apache2)"
silent: true
vars:
REPO: '{{.REPO | default ""}}'
preconditions:
- sh: '[ -n "{{.REPO}}" ]'
msg: "REPO is required. Usage: task mark-repo-read REPO=owner/repo"
cmds:
- |
#!/usr/bin/env fish
set REPO "{{.REPO}}"
set_color '#88C0D0'
echo ""
echo " Marking notifications read for: $REPO"
echo " ══════════════════════════════════════════════════"
set_color normal
set tmpfile (mktemp)
gh api /notifications --paginate --jq '.[]' | jq -s --arg repo "$REPO" '
[ .[] | select(.repository.full_name == $repo) ]
' > $tmpfile
set count (jq 'length' < $tmpfile)
if test $count -eq 0
set_color '#A3BE8C'
echo " No unread notifications found for $REPO"
set_color normal
rm $tmpfile
echo ""
exit 0
end
set_color '#EBCB8B'
echo " Found $count notification(s) — marking as read..."
set_color normal
set marked 0
for id in (jq -r '.[].id' < $tmpfile)
gh api --method PATCH /notifications/threads/$id > /dev/null
set marked (math $marked + 1)
end
rm $tmpfile
echo ""
set_color '#A3BE8C'
echo " ✔ Marked $marked notification(s) as read for $REPO"
set_color normal
echo ""
# ===========================================================================
# WORKFLOW & RELEASE PIPELINE
# ===========================================================================
# ---------------------------------------------------------------------------
# cancel-runs: Bulk-cancel in-progress GitHub Actions workflow runs
# Wraps: scripts/cancel-workflow-runs.sh
# ---------------------------------------------------------------------------
cancel-runs:
desc: "Cancel all in-progress Actions runs for ORG (default: sous-chefs). Pass REPO=name to target one repo."
silent: true
vars:
ORG: '{{.ORG | default "sous-chefs"}}'
REPO: '{{.REPO | default ""}}'
cmds:
- |
#!/usr/bin/env fish
set_color '#88C0D0'
echo ""
echo " Cancel In-Progress Workflow Runs"
echo " ══════════════════════════════════════════════════"
set_color normal
if test -n "{{.REPO}}"
set_color '#EBCB8B'
echo " Target: {{.ORG}}/{{.REPO}}"
set_color normal
bash "{{.ROOT_DIR}}/scripts/cancel-workflow-runs.sh" "{{.ORG}}" "{{.REPO}}"
else
set_color '#EBCB8B'
echo " Target: all repos in {{.ORG}}"
set_color normal
bash "{{.ROOT_DIR}}/scripts/cancel-workflow-runs.sh" "{{.ORG}}"
end
# ---------------------------------------------------------------------------
# update-release-pipeline: Full 9-step cookbook migration to release pipeline
# Wraps: scripts/update-release-pipeline.sh
#
# NOTE: This script calls ./manage-webhooks.sh and ../manage-branch-protection.sh
# relative to the scripts/ directory. It must be run with the cookbook repo
# checked out as a sibling of the scripts/ directory (i.e. in meta/).
# The REPO directory must exist relative to the project root.
# ---------------------------------------------------------------------------
update-release-pipeline:
desc: "Full release pipeline migration for REPO=<cookbook-name> (9 steps: webhooks → branch → workflows → release-please → changelog → lint → commit → PR → branch-protection)"
silent: true
vars:
REPO: '{{.REPO | default ""}}'
preconditions:
- sh: '[ -n "{{.REPO}}" ]'
msg: "REPO is required. Usage: task update-release-pipeline REPO=isc_kea"
- sh: '[ -d "{{.ROOT_DIR}}/{{.REPO}}" ]'
msg: "Cookbook directory not found at {{.ROOT_DIR}}/{{.REPO}} — clone it there first"
cmds:
- |
#!/usr/bin/env fish
set_color '#88C0D0'
echo ""
echo " Release Pipeline Migration: {{.REPO}}"
echo " ══════════════════════════════════════════════════"
set_color normal
# update-release-pipeline.sh has inter-script relative-path dependencies:
# ./manage-webhooks.sh (same dir as script)
# ../manage-branch-protection.sh (parent of cwd after cd into repo)
#
# We build a temp workspace where these paths resolve correctly:
# workspace/
# update-release-pipeline.sh → symlink
# manage-webhooks.sh → symlink (./ ✓)
# manage-branch-protection.sh → symlink (../ from workspace/REPO/ ✓)
# {{.REPO}}/ → symlink to real repo
set workspace "/tmp/sc-migration-{{.REPO}}"
rm -rf $workspace
mkdir -p $workspace
set scripts "{{.ROOT_DIR}}/scripts"
ln -s "$scripts/update-release-pipeline.sh" "$workspace/update-release-pipeline.sh"
ln -s "$scripts/manage-webhooks.sh" "$workspace/manage-webhooks.sh"
ln -s "$scripts/manage-branch-protection.sh" "$workspace/manage-branch-protection.sh"
ln -s "{{.ROOT_DIR}}/{{.REPO}}" "$workspace/{{.REPO}}"
cd $workspace
bash update-release-pipeline.sh "{{.REPO}}"
set exit_code $status
rm -rf $workspace
exit $exit_code
# ---------------------------------------------------------------------------
# create-workflow-branches: Create workflow-overhaul branches across repos
# Wraps: scripts/create-workflow-branches.fish
# REPOS_PATH: directory containing the checked-out cookbook repos
# ---------------------------------------------------------------------------
create-workflow-branches:
desc: "Create workflow-overhaul branches and commits for all repos in REPOS_PATH=/path/to/repos"
silent: true
vars:
REPOS_PATH: '{{.REPOS_PATH | default ""}}'
preconditions:
- sh: '[ -n "{{.REPOS_PATH}}" ]'
msg: "REPOS_PATH is required. Usage: task create-workflow-branches REPOS_PATH=/path/to/repos"
- sh: '[ -d "{{.REPOS_PATH}}" ]'
msg: "REPOS_PATH directory does not exist: {{.REPOS_PATH}}"
cmds:
- |
#!/usr/bin/env fish
set_color '#88C0D0'
echo ""
echo " Create Workflow-Overhaul Branches"
echo " ══════════════════════════════════════════════════"
set_color '#EBCB8B'
echo " Repos path: {{.REPOS_PATH}}"
set_color normal
# Rewrite hardcoded path to the user-supplied REPOS_PATH
set script "{{.ROOT_DIR}}/scripts/create-workflow-branches.fish"
set tmpscript (mktemp --suffix .fish)
sed 's|/Users/damacus/repos/sous-chefs|{{.REPOS_PATH}}|g' $script > $tmpscript
fish $tmpscript
set exit_code $status
rm $tmpscript
exit $exit_code
# ---------------------------------------------------------------------------
# create-workflow-prs: Push workflow-overhaul branches and open PRs
# Wraps: scripts/create-prs.fish
# REPOS_PATH: directory containing the checked-out cookbook repos
# ---------------------------------------------------------------------------
create-workflow-prs:
desc: "Push workflow-overhaul branches and create PRs for repos in REPOS_PATH=/path/to/repos"
silent: true
vars:
REPOS_PATH: '{{.REPOS_PATH | default ""}}'
preconditions:
- sh: '[ -n "{{.REPOS_PATH}}" ]'
msg: "REPOS_PATH is required. Usage: task create-workflow-prs REPOS_PATH=/path/to/repos"
- sh: '[ -d "{{.REPOS_PATH}}" ]'
msg: "REPOS_PATH directory does not exist: {{.REPOS_PATH}}"
cmds:
- |
#!/usr/bin/env fish
set_color '#88C0D0'
echo ""
echo " Create Pull Requests — Workflow Overhaul"
echo " ══════════════════════════════════════════════════"
set_color '#EBCB8B'
echo " Repos path: {{.REPOS_PATH}}"
set_color normal
set script "{{.ROOT_DIR}}/scripts/create-prs.fish"
set tmpscript (mktemp --suffix .fish)
sed 's|/Users/damacus/repos/sous-chefs|{{.REPOS_PATH}}|g' $script > $tmpscript
fish $tmpscript
set exit_code $status
rm $tmpscript
exit $exit_code
# ---------------------------------------------------------------------------
# list-release-prs: Find and open matching release PRs in the browser
# Wraps: scripts/list-release-prs.fish
# REPOS_PATH: directory containing checked-out repos (uses find . to discover)
# PATTERN: PR title substring to match (default: "chore(main): release")
# ---------------------------------------------------------------------------
list-release-prs:
desc: "Find and open release PRs in browser. REPOS_PATH= required, PATTERN= optional (default: 'chore(main): release')"
silent: true
vars:
PATTERN: '{{.PATTERN | default "chore(main): release"}}'
REPOS_PATH: '{{.REPOS_PATH | default ""}}'
preconditions:
- sh: '[ -n "{{.REPOS_PATH}}" ]'
msg: "REPOS_PATH is required. Usage: task list-release-prs REPOS_PATH=/path/to/repos"
- sh: '[ -d "{{.REPOS_PATH}}" ]'
msg: "REPOS_PATH directory does not exist: {{.REPOS_PATH}}"
cmds:
- |
#!/usr/bin/env fish
set_color '#88C0D0'
echo ""
echo " List Release PRs"
echo " ══════════════════════════════════════════════════"
set_color '#EBCB8B'
echo " Pattern : {{.PATTERN}}"
echo " Repos path: {{.REPOS_PATH}}"
set_color normal
echo ""
# Script uses `find .` — cd to the repos directory first
cd "{{.REPOS_PATH}}"
fish "{{.ROOT_DIR}}/scripts/list-release-prs.fish" "{{.PATTERN}}"
# ---------------------------------------------------------------------------
# force-merge-prs: Admin force-merge matching PRs across repos
# Wraps: force-merge-prs.fish (repo root)
# REPOS_PATH: directory containing checked-out repos
# PATTERN: PR title substring to match (default: "chore(main): release")
#
# WARNING: Uses --admin to bypass branch protection. Prompts for confirmation.
# ---------------------------------------------------------------------------
force-merge-prs:
desc: "Admin force-merge PRs matching PATTERN across repos in REPOS_PATH. REPOS_PATH= required, PATTERN= optional."
silent: true
vars:
PATTERN: '{{.PATTERN | default "chore(main): release"}}'
REPOS_PATH: '{{.REPOS_PATH | default ""}}'
preconditions:
- sh: '[ -n "{{.REPOS_PATH}}" ]'
msg: "REPOS_PATH is required. Usage: task force-merge-prs REPOS_PATH=/path/to/repos"
- sh: '[ -d "{{.REPOS_PATH}}" ]'
msg: "REPOS_PATH directory does not exist: {{.REPOS_PATH}}"
cmds:
- |
#!/usr/bin/env fish
set_color '#BF616A'
echo ""
echo " ⚠ Force Merge PRs — Admin Bypass"
echo " ══════════════════════════════════════════════════"
set_color '#EBCB8B'
echo " Pattern : {{.PATTERN}}"
echo " Repos path: {{.REPOS_PATH}}"
set_color normal
echo ""
set script "{{.ROOT_DIR}}/force-merge-prs.fish"
set tmpscript (mktemp --suffix .fish)
sed 's|/Users/damacus/repos/sous-chefs|{{.REPOS_PATH}}|g' $script > $tmpscript
# Script uses `find .` to discover repos — run from REPOS_PATH
cd "{{.REPOS_PATH}}"
fish $tmpscript "{{.PATTERN}}"
set exit_code $status
rm $tmpscript
exit $exit_code
# ===========================================================================
# BRANCH PROTECTION
# ===========================================================================
# ---------------------------------------------------------------------------
# branch-protection: Update required status checks on the main branch
# Wraps: scripts/manage-branch-protection.sh
# ---------------------------------------------------------------------------
branch-protection:
desc: "Update branch protection status checks on main for REPO=owner/repo (auto-detects current repo if omitted)"
silent: true
vars:
REPO: '{{.REPO | default ""}}'
cmds:
- |
#!/usr/bin/env fish
set_color '#88C0D0'
echo ""
echo " Branch Protection Manager"
echo " ══════════════════════════════════════════════════"
set_color normal
if test -n "{{.REPO}}"
set_color '#EBCB8B'
echo " Repo: {{.REPO}}"
set_color normal
bash "{{.ROOT_DIR}}/scripts/manage-branch-protection.sh" "{{.REPO}}"
else
set_color '#EBCB8B'
echo " Repo: auto-detect from git remote"
set_color normal
bash "{{.ROOT_DIR}}/scripts/manage-branch-protection.sh"
end
# ===========================================================================
# WEBHOOK MANAGEMENT
# ===========================================================================
# ---------------------------------------------------------------------------
# webhooks-check: Show webhook status for repos in sous-chefs org
# Wraps: scripts/manage-webhooks.sh check
# REPOS: space-separated repo names (short names, not owner/repo)
# If omitted, the script uses its default sample list.
# ---------------------------------------------------------------------------
webhooks-check:
desc: "Show webhook status for repos in sous-chefs. Pass REPOS='apache2 iis' or omit for default list."
silent: true
vars:
REPOS: '{{.REPOS | default ""}}'
cmds:
- |
#!/usr/bin/env fish
set_color '#88C0D0'
echo ""
echo " Webhook Status Check — sous-chefs"
echo " ══════════════════════════════════════════════════"
if test -n "{{.REPOS}}"
set_color '#EBCB8B'
echo " Repos: {{.REPOS}}"
set_color normal
bash "{{.ROOT_DIR}}/scripts/manage-webhooks.sh" check {{.REPOS}}
else
set_color '#EBCB8B'
echo " Repos: default list (see scripts/manage-webhooks.sh)"
set_color normal
bash "{{.ROOT_DIR}}/scripts/manage-webhooks.sh" check
end
# ---------------------------------------------------------------------------
# webhooks-disable: Disable active webhooks for repos in sous-chefs org
# Wraps: scripts/manage-webhooks.sh disable
# REPOS: space-separated repo names (short names, not owner/repo)
# If omitted, the script uses its default sample list.
# ---------------------------------------------------------------------------
webhooks-disable:
desc: "Disable active webhooks for repos in sous-chefs. Pass REPOS='apache2 iis' or omit for default list."
silent: true
vars:
REPOS: '{{.REPOS | default ""}}'
cmds:
- |
#!/usr/bin/env fish
set_color '#88C0D0'
echo ""
echo " Webhook Disable — sous-chefs"
echo " ══════════════════════════════════════════════════"
if test -n "{{.REPOS}}"
set_color '#EBCB8B'
echo " Repos: {{.REPOS}}"
set_color normal
bash "{{.ROOT_DIR}}/scripts/manage-webhooks.sh" disable {{.REPOS}}
else
set_color '#EBCB8B'
echo " Repos: default list (see scripts/manage-webhooks.sh)"
set_color normal
bash "{{.ROOT_DIR}}/scripts/manage-webhooks.sh" disable
end
# ===========================================================================
# ORG AUDIT & VISIBILITY
# ===========================================================================
# ---------------------------------------------------------------------------
# migration-status: Release pipeline migration progress across all repos.
# Checks for release-please-config.json via GitHub code search (fast, no
# local clones). Results may lag a few minutes after a recent push.
# Optional: FILTER=<substr> to narrow by repo name.
# ---------------------------------------------------------------------------
migration-status:
desc: "Show release pipeline migration progress across all {{.ORG}} repos. Optional: FILTER=<name>"
silent: true
vars:
FILTER: '{{.FILTER | default ""}}'
cmds:
- |
#!/usr/bin/env fish
set org "{{.ORG}}"
set filter "{{.FILTER}}"
set_color '#88C0D0'
echo ""
echo " Release Pipeline Migration Status — $org"
echo " ══════════════════════════════════════════════════"
set_color normal
set_color '#EBCB8B'
echo " Fetching repo list..."
set_color normal
set all_repos (gh repo list $org --limit 1000 \
--json name,isArchived \
--jq '[.[] | select(.isArchived == false)] | .[].name' | sort)
if test -n "$filter"
set all_repos (string match -a "*$filter*" $all_repos)
set_color '#EBCB8B'
echo " Filter: $filter"
set_color normal
end
set total (count $all_repos)
set_color '#EBCB8B'
echo " Searching for migrated repos via code search..."
set_color normal
# Code search for repos containing release-please-config.json
# (rate: 10 req/min auth'd; 100 results/page; max 1000 total)
set migrated_search (gh api \
"search/code?q=filename%3Arelease-please-config.json+org%3A$org&per_page=100" \
--paginate \
--jq '.items[].repository.name' 2>/dev/null | sort | uniq)
set migrated_list
set not_migrated_list
for repo in $all_repos
if contains $repo $migrated_search
set migrated_list $migrated_list $repo
else
set not_migrated_list $not_migrated_list $repo
end
end
set migrated_count (count $migrated_list)
set not_count (count $not_migrated_list)
set pct 0
if test $total -gt 0
set pct (math --scale=0 "floor($migrated_count * 100 / $total)")
end
# Progress bar
set filled (math --scale=0 "floor($pct / 5)")
set empty (math "20 - $filled")
set bar (string repeat -n $filled "█")(string repeat -n $empty "░")
echo ""
set_color '#A3BE8C'
echo " [$bar] $pct% — $migrated_count / $total repos migrated"
set_color normal
echo ""
if test $not_count -gt 0
set_color '#EBCB8B'
echo " Not yet migrated ($not_count):"
set_color normal
for repo in $not_migrated_list
set_color '#BF616A'
echo " ❌ $repo"
set_color normal
end
echo ""
set_color '#88C0D0'
echo " To migrate: task update-release-pipeline REPO=<name>"
set_color normal
else
set_color '#A3BE8C'
echo " All repos have been migrated!"
set_color normal
end
echo ""
# ---------------------------------------------------------------------------
# open-prs: All open PRs across the org in one table.
# Uses gh search (fast). Age-coloured: green <7d, yellow 7-30d, red >30d.
# Optional: FILTER=<repo-substr>, AUTHOR=<login>, LABEL=<label-name>
# ---------------------------------------------------------------------------
open-prs:
desc: "Show all open PRs in {{.ORG}}. Optional: FILTER=<repo>, AUTHOR=<login>, LABEL=<label>"
silent: true
vars:
FILTER: '{{.FILTER | default ""}}'
AUTHOR: '{{.AUTHOR | default ""}}'
LABEL: '{{.LABEL | default ""}}'
cmds:
- |
#!/usr/bin/env fish
set org "{{.ORG}}"
set filter "{{.FILTER}}"
set author "{{.AUTHOR}}"
set label "{{.LABEL}}"
set_color '#88C0D0'
echo ""
echo " Open Pull Requests — $org"
echo " ══════════════════════════════════════════════════"
set_color '#EBCB8B'
if test -n "$filter"; echo " Filter : $filter"; end
if test -n "$author"; echo " Author : $author"; end
if test -n "$label"; echo " Label : $label"; end
set_color normal
set search_args --owner $org --state open --limit 500 --sort updated
set search_args $search_args --json number,title,repository,author,createdAt,labels
if test -n "$author"
set search_args $search_args --author $author
end
if test -n "$label"
set search_args $search_args --label $label
end
set tmpfile (mktemp)
gh search prs $search_args > $tmpfile 2>/dev/null
if test -n "$filter"
set filtered (mktemp)
jq --arg f "$filter" '[.[] | select(.repository.name | contains($f))]' \
< $tmpfile > $filtered
mv $filtered $tmpfile
end
set total (jq 'length' < $tmpfile)
if test "$total" -eq 0
set_color '#A3BE8C'
echo ""
echo " No open PRs found"
set_color normal
rm $tmpfile
echo ""
exit 0
end
echo ""
set_color '#EBCB8B'
printf " %-35s %-5s %-14s %s\n" "REPO" "#PR" "AUTHOR" "TITLE"
printf " %-35s %-5s %-14s %s\n" \