From 7828f1ac393b37880604e6262ffeba352a749cdf Mon Sep 17 00:00:00 2001
From: Alexander Kovalenko <alexander.kovalenko@spryker.com>
Date: Tue, 18 Jun 2024 18:41:47 +0300
Subject: [PATCH] Fix

---
 .github/workflows/test.yml | 44 ++++++++++++++++++++++----------------
 1 file changed, 25 insertions(+), 19 deletions(-)

diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index a44c4d92..9ba396c0 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -100,26 +100,32 @@ jobs:
           affectedCmd: npx nx affected:test
           isDev: ${{ env.IS_DEV }}
 
-  set-env-visual-pr:
-    runs-on: ubuntu-latest
-    outputs:
-      should-run: ${{ steps.set-env.outputs.should-run }}
-    steps:
-      - name: Set should-run
-        id: set-env
-        run: |
-          echo "CHROMATIC_PROJECT_TOKEN=${{ secrets.CHROMATIC_PROJECT_TOKEN }}"
-          if [ "${{ github.event_name }}" = "pull_request" ] && [ -n "${{ secrets.CHROMATIC_PROJECT_TOKEN }}" ]; then
-            echo "::set-output name=should-run::true"
-          else
-            echo "::set-output name=should-run::false"
-          fi
+  jobs:
+    set-env:
+      runs-on: ubuntu-latest
+      outputs:
+        should-run-pr: ${{ steps.set-env.outputs.should-run-pr }}
+        should-run-push: ${{ steps.set-env.outputs.should-run-push }}
+      steps:
+        - name: Set should-run for PR
+          id: set-env
+          run: |
+            echo "CHROMATIC_PROJECT_TOKEN=${{ secrets.CHROMATIC_PROJECT_TOKEN }}"
+            if [ "${{ github.event_name }}" = "pull_request" ] && [ -n "${{ secrets.CHROMATIC_PROJECT_TOKEN }}" ]; then
+              echo "::set-output name=should-run-pr::true"
+            else
+              echo "::set-output name=should-run-pr::false"
+            fi
+            if [ "${{ github.event_name }}" = "push" ] && [ -n "${{ secrets.CHROMATIC_PROJECT_TOKEN }}" ]; then
+              echo "::set-output name=should-run-push::true"
+            else
+              echo "::set-output name=should-run-push::false"
+            fi
 
   test-visual-pr:
     runs-on: ubuntu-latest
-    needs:
-      [test-format, test-lint, test-stylelint, test-tsconfig, set-env-visual-pr]
-    if: needs.set-env.outputs.should-run == 'true'
+    needs: [test-format, test-lint, test-stylelint, test-tsconfig, set-env]
+    if: needs.set-env.outputs.should-run-pr == 'true'
     steps:
       - uses: actions/checkout@v3
         with:
@@ -135,8 +141,8 @@ jobs:
 
   test-visual-dev:
     runs-on: ubuntu-latest
-    needs: [test-format, test-lint, test-stylelint, test-tsconfig]
-    if: ${{ github.event_name == 'push' }}
+    needs: [test-format, test-lint, test-stylelint, test-tsconfig, set-env]
+    if: needs.set-env.outputs.should-run-push == 'true'
     steps:
       - uses: actions/checkout@v3
         with: