diff --git a/.github/actions/restore-cache/action.yml b/.github/actions/restore-cache/action.yml index 0bbd975680..fcd4fddbeb 100644 --- a/.github/actions/restore-cache/action.yml +++ b/.github/actions/restore-cache/action.yml @@ -1,5 +1,5 @@ -name: "Restore dependency cache" -description: "Restore the dependency cache." +name: "Restore dependency & build cache" +description: "Restore the dependency & build cache." runs: using: "composite" @@ -11,8 +11,15 @@ runs: path: ${{ env.CACHED_DEPENDENCY_PATHS }} key: ${{ env.DEPENDENCY_CACHE_KEY }} + - name: Check build cache + uses: actions/cache/restore@v3 + id: build-cache + with: + path: ${{ env.CACHED_BUILD_PATHS }} + key: ${{ github.sha }} + - name: Check if caches are restored uses: actions/github-script@v6 - if: steps.dep-cache.outputs.cache-hit != 'true' + if: steps.dep-cache.outputs.cache-hit != 'true' || steps.build-cache.outputs.cache-hit != 'true' with: - script: core.setFailed('Dependency cache could not be restored - please re-run ALL jobs.') \ No newline at end of file + script: core.setFailed('Dependency or build cache could not be restored - please re-run ALL jobs.') \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9a05123805..5c4bf97c64 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,8 +18,9 @@ env: ${{ github.workspace }}/node_modules ${{ github.workspace }}/apps/*/node_modules ${{ github.workspace }}/ghost/*/node_modules - ${{ github.workspace }}/ghost/*/build ~/.cache/ms-playwright/ + CACHED_BUILD_PATHS: | + ${{ github.workspace }}/ghost/*/build concurrency: group: ${{ github.head_ref || github.run_id }} @@ -131,6 +132,13 @@ jobs: path: ${{ env.CACHED_DEPENDENCY_PATHS }} key: ${{ steps.compute_lockfile_hash.outputs.hash }} + - name: Check build cache + uses: actions/cache@v3 + id: cache_built_packages + with: + path: ${{ env.CACHED_BUILD_PATHS }} + key: ${{ env.HEAD_COMMIT }} + - name: Set up Node uses: actions/setup-node@v3 if: steps.cache_dependencies.outputs.cache-hit != 'true' @@ -143,6 +151,10 @@ jobs: - name: Install dependencies if: steps.cache_dependencies.outputs.cache-hit != 'true' run: yarn install --prefer-offline --frozen-lockfile + + - name: Build packages + if: steps.cache_built_packages.outputs.cache-hit != 'true' + run: yarn prepare outputs: dependency_cache_key: ${{ steps.compute_lockfile_hash.outputs.hash }}