From 1f6ced5e0bced13a6b131093eaff9aaf8c01e4ec Mon Sep 17 00:00:00 2001 From: Cedric van Putten Date: Tue, 19 Sep 2023 10:25:05 +0200 Subject: [PATCH] chore: add build cache to packages workflow --- .github/actions/setup-cache/action.yml | 28 ++++++++++++++++++++++++++ .github/workflows/packages.yml | 6 +++++- 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 .github/actions/setup-cache/action.yml diff --git a/.github/actions/setup-cache/action.yml b/.github/actions/setup-cache/action.yml new file mode 100644 index 00000000..3011c511 --- /dev/null +++ b/.github/actions/setup-cache/action.yml @@ -0,0 +1,28 @@ +name: Setup Cache +description: Prepare Snack's build cache in GitHub Actions + +runs: + using: composite + steps: + - name: ♻️ Find modules cache + id: modules-cache + run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT + shell: bash + + - name: ♻️ Restore modules cache + uses: actions/cache@v3 + with: + path: ${{ steps.modules-cache.outputs.dir }} + key: yarn-TEST_1-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + yarn-TEST_1-${{ runner.os }}- + + - name: ♻️ Restore build cache + uses: actions/cache@v3 + with: + key: turbo-TEST_3-${{ runner.os }}-${{ github.sha }} + restore-keys: | + turbo-TEST_3-${{ runner.os }}- + path: | + node_modules/.cache/turbo + packages/*/.turbo diff --git a/.github/workflows/packages.yml b/.github/workflows/packages.yml index 354df791..306184c7 100644 --- a/.github/workflows/packages.yml +++ b/.github/workflows/packages.yml @@ -8,6 +8,7 @@ on: workflow_dispatch: pull_request: paths: + - .github/actions/setup-cache/** - .github/workflows/packages.yml - packages/** - .eslint* @@ -17,6 +18,7 @@ on: push: branches: [main] paths: + - .github/actions/setup-cache/** - .github/workflows/packages.yml - packages/** - .eslint* @@ -54,7 +56,9 @@ jobs: uses: actions/setup-node@v3 with: node-version: 18.x - cache: yarn + + - name: 🏗 Setup cache + uses: ./.github/actions/setup-cache - name: 📦 Install monorepo dependencies run: yarn install --frozen-lockfile