From 7274a978ab7353d531ca41a222f2be5db4f04181 Mon Sep 17 00:00:00 2001
From: Ariya Hidayat <ariya@metabase.com>
Date: Mon, 6 Jun 2022 15:17:14 -0700
Subject: [PATCH] Github Actions CI: allow skipping the dependency cache
 (#23134)

---
 .github/actions/prepare-backend/action.yml  | 5 +++++
 .github/actions/prepare-cypress/action.yml  | 5 +++++
 .github/actions/prepare-frontend/action.yml | 8 ++++++++
 3 files changed, 18 insertions(+)

diff --git a/.github/actions/prepare-backend/action.yml b/.github/actions/prepare-backend/action.yml
index 285248c97b8..e80b8868797 100644
--- a/.github/actions/prepare-backend/action.yml
+++ b/.github/actions/prepare-backend/action.yml
@@ -24,8 +24,13 @@ runs:
       run: |
         curl -O https://download.clojure.org/install/linux-install-${{ inputs.clojure-version }}.sh &&
         sudo bash ./linux-install-${{ inputs.clojure-version }}.sh
+    - name: Check to see if dependencies should be cached
+      if: ${{ contains(github.event.head_commit.message, '[ci nocache]') }}
+      run: echo "Commit message includes [ci nocache]; dependencies will NOT be cached"
+      shell: bash
     - name: Get M2 cache
       uses: actions/cache@v2
+      if: ${{ !contains(github.event.head_commit.message, '[ci nocache]') }}
       with:
         path: |
           ~/.m2
diff --git a/.github/actions/prepare-cypress/action.yml b/.github/actions/prepare-cypress/action.yml
index 85cfc8d0c34..904fad634ea 100644
--- a/.github/actions/prepare-cypress/action.yml
+++ b/.github/actions/prepare-cypress/action.yml
@@ -2,8 +2,13 @@ name: Prepare cypress environment
 runs:
   using: "composite"
   steps:
+    - name: Check to see if dependencies should be cached
+      if: ${{ contains(github.event.head_commit.message, '[ci nocache]') }}
+      run: echo "Commit message includes [ci nocache]; dependencies will NOT be cached"
+      shell: bash
     - name: Get Cypress cache
       uses: actions/cache@v2
+      if: ${{ !contains(github.event.head_commit.message, '[ci nocache]') }}
       with:
         path: ~/.cache/Cypress
         key: ${{ runner.os }}-Cypress-${{ hashFiles('**/yarn.lock') }}
diff --git a/.github/actions/prepare-frontend/action.yml b/.github/actions/prepare-frontend/action.yml
index 0274118a131..3ce335bc916 100644
--- a/.github/actions/prepare-frontend/action.yml
+++ b/.github/actions/prepare-frontend/action.yml
@@ -7,13 +7,21 @@ runs:
       with:
         node-version: 14.x
         cache: 'yarn'
+    - name: Check to see if dependencies should be cached
+      if: ${{ contains(github.event.head_commit.message, '[ci nocache]') }}
+      run: |
+        echo "Commit message includes [ci nocache]; dependencies will NOT be cached"
+        yarn cache clean
+      shell: bash
     - name: Get M2 cache
       uses: actions/cache@v2
+      if: ${{ !contains(github.event.head_commit.message, '[ci nocache]') }}
       with:
         path: ~/.m2
         key: ${{ runner.os }}-cljs-${{ hashFiles('**/shadow-cljs.edn') }}
     - name: Get node_modules cache
       uses: actions/cache@v2
+      if: ${{ !contains(github.event.head_commit.message, '[ci nocache]') }}
       with:
         path: node_modules
         key: ${{ runner.os }}-node-modules-${{ hashFiles('**/yarn.lock') }}
-- 
GitLab