Skip to content

Commit

Permalink
use computed cache key
Browse files Browse the repository at this point in the history
  • Loading branch information
compojoom committed Dec 17, 2024
1 parent cf65388 commit 13d7d88
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
22 changes: 18 additions & 4 deletions .github/actions/cache-deps/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,24 @@ inputs:
mode:
description: "restore-yarn | save-yarn | restore-nc | safe-nc"
required: true
key:
description: "The cache key to use to safe. Attention! Make sure to use the correct computed cache key depending on the mode"
required: false

outputs:
cache-hit-yarn:
value: ${{ steps.restore.outputs.cache-hit }}
description: "Whether the cache was hit or not"
computed-cache-key-yarn:
value: ${{ steps.restore.outputs.cache-primary-key }}
description: "The computed cache key for yarn"
cache-hit-nc:
value: ${{ steps.restore-nc.outputs.cache-hit }}
description: "Whether the cache was hit or not"
computed-cache-key-nc:
value: ${{ steps.restore-nc.outputs.cache-primary-key }}
description: "The computed cache key for nextjs/cypress"

runs:
using: "composite"
steps:
Expand All @@ -31,7 +41,9 @@ runs:
- name: Set composite outputs yarn
if: ${{ inputs.mode == 'restore-yarn' }}
shell: bash
run: echo "cache-hit-yarn=${{ steps.restore.outputs.cache-hit }}" >> $GITHUB_OUTPUT
run: |
echo "cache-hit-yarn=${{ steps.restore.outputs.cache-hit }}" >> $GITHUB_OUTPUT
echo "computed-cache-key-yarn=${{ steps.restore.outputs.cache-primary-key }}" >> $GITHUB_OUTPUT
- name: Save Yarn Cache
if: ${{ inputs.mode == 'save-yarn' }}
Expand All @@ -41,7 +53,7 @@ runs:
**/node_modules
${{ github.workspace }}/.yarn/install-state.gz
${{ github.workspace }}/src/types
key: ${{ runner.os }}-web-core-modules-${{ hashFiles('**/package.json','**/yarn.lock') }}
key: ${{inputs.key}}

- name: Restore Nextjs/Cypress Cache
if: ${{ inputs.mode == 'restore-nc' }}
Expand All @@ -58,7 +70,9 @@ runs:
- name: Set composite outputs nc
if: ${{ inputs.mode == 'restore-nc' }}
shell: bash
run: echo "cache-hit-nc=${{ steps.restore-nc.outputs.cache-hit }}" >> $GITHUB_OUTPUT
run: |
echo "cache-hit-nc=${{ steps.restore-nc.outputs.cache-hit }}" >> $GITHUB_OUTPUT
echo "computed-cache-key-nc=${{ steps.restore-nc.outputs.cache-primary-key }}" >> $GITHUB_OUTPUT
- name: Save Nextjs/Cypress Cache
Expand All @@ -68,4 +82,4 @@ runs:
path: |
${{ github.workspace }}/.next/cache
/home/runner/.cache/Cypress
key: ${{ runner.os }}-nextjs-cypress-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
key: ${{inputs.key}}
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ jobs:
uses: ./.github/actions/cache-deps
with:
mode: save-yarn
key: ${{ steps.restore-yarn-types.outputs.computed-cache-key-yarn }}

eslint:
needs: build
Expand Down Expand Up @@ -143,6 +144,7 @@ jobs:
uses: ./.github/actions/cache-deps
with:
mode: save-nc
key: ${{ steps.restore-nc.outputs.computed-cache-key-nc }}
#- uses: ./.github/workflows/build-storybook

- name: Configure AWS credentials
Expand Down

0 comments on commit 13d7d88

Please sign in to comment.