From 22576258d91560f268e26c9a0feeb75c0eaf35b8 Mon Sep 17 00:00:00 2001
From: Alexander Polyankin <alexander.polyankin@metabase.com>
Date: Wed, 5 Jan 2022 20:33:02 +0300
Subject: [PATCH] Add yarn caching to chromatic (#19540)

---
 .github/workflows/chromatic.yml | 19 -------------------
 .github/workflows/frontend.yml  | 28 ++++++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 19 deletions(-)
 delete mode 100644 .github/workflows/chromatic.yml

diff --git a/.github/workflows/chromatic.yml b/.github/workflows/chromatic.yml
deleted file mode 100644
index 51cfd046fea..00000000000
--- a/.github/workflows/chromatic.yml
+++ /dev/null
@@ -1,19 +0,0 @@
-name: 'Chromatic'
-
-on: push
-
-jobs:
-  chromatic-deployment:
-    runs-on: ubuntu-latest
-    steps:
-      - name: Checkout repository
-        uses: actions/checkout@v2
-        with:
-          fetch-depth: 0
-      - name: Install dependencies
-        run: yarn
-      - name: Publish to Chromatic
-        uses: chromaui/action@v1
-        with:
-          token: ${{ secrets.GITHUB_TOKEN }}
-          projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
diff --git a/.github/workflows/frontend.yml b/.github/workflows/frontend.yml
index aa8726b8ad7..b6ba6364aa4 100644
--- a/.github/workflows/frontend.yml
+++ b/.github/workflows/frontend.yml
@@ -150,3 +150,31 @@ jobs:
     - run: yarn install --frozen-lockfile --prefer-offline
     - run: yarn run test-timezones
       name: Run frontend timezones tests
+
+  fe-chromatic:
+    runs-on: ubuntu-latest
+    steps:
+      - name: Checkout repository
+        uses: actions/checkout@v2
+        with:
+          fetch-depth: 0
+      - name: Prepare Node.js
+        uses: actions/setup-node@v1
+        with:
+          node-version: 14.x
+      - name: Get yarn cache
+        uses: actions/cache@v2
+        with:
+          path: ~/.cache/yarn
+          key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
+      - name: Get node_modules cache
+        uses: actions/cache@v2
+        with:
+          path: node_modules
+          key: ${{ runner.os }}-node-modules-${{ hashFiles('**/yarn.lock') }}
+      - run: yarn install --frozen-lockfile --prefer-offline
+      - name: Publish to Chromatic
+        uses: chromaui/action@v1
+        with:
+          token: ${{ secrets.GITHUB_TOKEN }}
+          projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
-- 
GitLab