From 04f784dfef91564f3cfa8540e683e3c7a4c6e72f Mon Sep 17 00:00:00 2001
From: brandon s allbery kf8nh <allbery.b@gmail.com>
Date: Sat, 14 Dec 2024 21:12:50 -0500
Subject: [PATCH] try to alert (via webhook) when Mergify is stuck

Add a label "waiting too long" if a PR has "merge delay passed"
but is still open without any activity. Somewhat hacky, since
GitHub's API doesn't provide any real hooks for it so I'm guessing
at ways to try to catch it. Can only be tested by merging, since
Mergify won't apply it unless it's on `master`.
---
 .github/mergify.yml | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/.github/mergify.yml b/.github/mergify.yml
index 5864577f608..e01afbd5ed2 100644
--- a/.github/mergify.yml
+++ b/.github/mergify.yml
@@ -62,6 +62,31 @@ pull_request_rules:
       - check-success=Bootstrap post job
       - 'check-success=docs/readthedocs.org:cabal'
 
+  # label when Mergify didn't trigger a merge automatically
+  - actions:
+      label:
+        add:
+          - waiting too long
+    name: Mergify hasn't merged a PR yet
+    conditions:
+      - base=master
+      - -draft
+      - -closed
+      - -merged
+      - '#approved-reviews-by>=2'
+      - '#changes-requested-reviews-by=0'
+      - updated-at<4 days ago
+      - label=merge delay passed
+      # oy
+      # lifted these from branch protection imports
+      - check-success=fourmolu
+      - check-success=hlint
+      - check-success=Meta checks
+      - check-success=Doctest Cabal
+      - check-success=Validate post job
+      - check-success=Bootstrap post job
+      - 'check-success=docs/readthedocs.org:cabal'
+
   # rebase+merge strategy
   - actions:
       queue: