Skip to content

Commit

Permalink
custom action
Browse files Browse the repository at this point in the history
  • Loading branch information
Guang Qiu committed Dec 27, 2023
1 parent 187ef95 commit 33d1c29
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/cached_deps/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
name: 'Get & Cache Dependencies'
description: 'Get the dependencies (via npm) and cache them'
runs:
uses: 'composite'
steps:
- name: Cache Dependencies
id: cache
uses: actions/cache@v4
with:
path: node_modules
key: deps-node-modules-${{ hashFiles('**/package-lock.json') }}
- name: Install dependencies
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
run: npm ci
shell: bash
13 changes: 3 additions & 10 deletions .github/workflows/use-reusable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,9 @@ jobs:
steps:
- name: Get code
uses: actions/checkout@v3
- name: Cache dependencies
id: cache
uses: actions/cache@v3
with:
path: node_modules
key: deps-node-modules-${{ hashFiles('**/package-lock.json') }}
# check cache output result
- name: Install dependencies
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
run: npm ci
# composite custom action
- name: Load & cache dependencies
uses: ./.github/workflows/cached_deps
# for some reasons this lint command failed, I commented it out just for the sake of learning.
# I don't know how to fix it.
# - name: Lint code
Expand Down

0 comments on commit 33d1c29

Please sign in to comment.