From adf1f8ed3a9d756b6aef26c85048af9e69fa2eca Mon Sep 17 00:00:00 2001
From: ludamad <adam.domurad@gmail.com>
Date: Tue, 1 Oct 2024 09:21:20 -0400
Subject: [PATCH] fix: reenable CI reruns on master

Master typically has a commit already in by the time one finishes with fail status, so exempt it from the logic here that is meant to make PRs behave sanely. this also means the slack message will work again
---
 .github/workflows/rerun.yml | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/.github/workflows/rerun.yml b/.github/workflows/rerun.yml
index 9623ad4272a..16a1ca46f3c 100644
--- a/.github/workflows/rerun.yml
+++ b/.github/workflows/rerun.yml
@@ -1,5 +1,5 @@
 # adapted from https://github.com/orgs/community/discussions/67654
-# altered to not rerun if we are not the newest commit in the run's branch
+# altered to not rerun if we are not the newest commit in the run's branch (exception for master/main)
 on:
   workflow_dispatch:
     inputs:
@@ -44,8 +44,8 @@ jobs:
           LATEST_COMMIT_SHA=$(gh api repos/${{ github.repository }}/commits/$BRANCH_NAME --jq .sha)
 
           # Compare the SHAs
-          if [[ "$COMMIT_SHA" != "$LATEST_COMMIT_SHA" ]]; then
-            echo "Commit $COMMIT_SHA is not the latest commit on branch $BRANCH_NAME (latest is $LATEST_COMMIT_SHA). Skipping rerun."
+          if [[ "$COMMIT_SHA" != "$LATEST_COMMIT_SHA" ]] && [[ "$BRANCH_NAME" != "master" && "$BRANCH_NAME" != "main" ]] ; then
+            echo "Commit $COMMIT_SHA is not the latest commit on branch $BRANCH_NAME (latest is $LATEST_COMMIT_SHA) and the branch is not master/main. Skipping rerun."
           else
             echo "Commit $COMMIT_SHA is the latest on branch $BRANCH_NAME. Proceeding with rerun."
             gh run rerun ${{ inputs.run_id }} --failed