Skip to content

Commit

Permalink
Add Caching Action for Dependencies and Update Workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasCode92 committed Dec 12, 2024
1 parent f6dfb72 commit d2fcc18
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 4 deletions.
28 changes: 28 additions & 0 deletions .github/actions/cache-deps/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: "Get & Cache Dependencies"
description: "Get the dependencies (via npm) and cache them for later use."
inputs:
caching:
description: "Whether to cache the dependencies or not."
required: false
default: "true"
outputs:
used-cache:
description: "Whether the cache was used or not."
value: ${{ steps.install.outputs.cache }}
runs:
using: "composite"
steps:
- name: Cache dependencies
uses: actions/cache@v4
if: inputs.caching == 'true'
id: cache
with:
path: node_modules
key: deps-node-modules-${{ hashFiles('**/package-lock.json') }}
- name: Install dependencies
id: install
if: steps.cache.outputs.cache-hit != 'true' || inputs.caching != 'true'
shell: bash
run: |
npm ci
echo "cache='${{ inputs.caching }}'" >> $GITHUB_OUTPUT
13 changes: 9 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: "20.11.1"
- name: Install dependencies
run: npm install
- name: Load & cache dependencies
uses: ./.github/actions/cached-deps
with:
caching: "false"
- name: Run tests
run: npm test
build:
Expand All @@ -30,8 +32,11 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: "20.11.1"
- name: Install dependencies
run: npm install
- name: Load & cache dependencies
id: chached-deps
uses: ./.github/actions/cached-deps
- name: Output information
run: echo "Cache used? ${{ steps.chached-deps.outputs.used-cache }}"
- name: Build the application
run: npm run build
- name: Upload artifacts
Expand Down
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
"material-icon-theme.files.associations": {
".tool-versions": "nodejs_alt"
},
"material-icon-theme.folders.associations": {
"actions": "gh-workflows",
"cache-deps": "temp"
},
"tailwindCSS.experimental.classRegex": [
["[cC]lasses\\s*\\+?=\\s*([^;]*);", "'([^']*)'"],
["[cC]lasses\\s*\\+?=\\s*([^;]*);", "\"([^\"]*)\""],
Expand Down

0 comments on commit d2fcc18

Please sign in to comment.