From f1de2eeed2d163eeef2ef28d87513d013d216f0d Mon Sep 17 00:00:00 2001
From: Evan Mullins <evanrm@gmail.com>
Date: Thu, 5 Dec 2024 16:01:31 -0500
Subject: [PATCH] auto retry workflow step when wp install fails

---
 .github/workflows/cypress-matrix.yml | 6 +++++-
 .github/workflows/cypress.yml        | 6 +++++-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/.github/workflows/cypress-matrix.yml b/.github/workflows/cypress-matrix.yml
index 8b08593..d390c92 100644
--- a/.github/workflows/cypress-matrix.yml
+++ b/.github/workflows/cypress-matrix.yml
@@ -115,7 +115,11 @@ jobs:
           echo '{"wpVersion": "${{ matrix.wpVersion }}","phpVersion": "${{ matrix.phpVersion }}"}' > cypress.env.json
 
       - name: Install WordPress
-        run: npx wp-env start --debug
+        uses: nick-fields/retry@v3
+        with:
+          timeout_minutes: 4
+          max_attempts: 3
+          command: npx wp-env start --debug
 
       - name: Run Cypress Tests
         if: ${{ github.repository != 'newfold-labs/wp-plugin-mojo' || github.actor == 'dependabot[bot]' }}
diff --git a/.github/workflows/cypress.yml b/.github/workflows/cypress.yml
index c481893..0790ee2 100644
--- a/.github/workflows/cypress.yml
+++ b/.github/workflows/cypress.yml
@@ -98,7 +98,11 @@ jobs:
         run: echo '{"config":{"WP_DEBUG_DISPLAY":false},"plugins":["${{ steps.workflow.outputs.DIST }}/${{ steps.workflow.outputs.PACKAGE }}"]}' > .wp-env.override.json
 
       - name: Install WordPress
-        run: npx @wordpress/env@latest start
+        uses: nick-fields/retry@v3
+        with:
+          timeout_minutes: 4
+          max_attempts: 3
+          command: npx wp-env start --debug
 
       - name: Run Cypress Tests
         if: ${{ github.repository != 'newfold-labs/wp-plugin-mojo' || github.actor == 'dependabot[bot]' }}