|
1 | | -name: 'My composite action' |
2 | | -description: 'Checks out the repository and install' |
| 1 | +name: Main action for Node.js |
| 2 | +description: Setup Node.js |
| 3 | + |
| 4 | +inputs: |
| 5 | + node-version: |
| 6 | + description: Node.js version |
| 7 | + required: false |
| 8 | + default: 20.x |
| 9 | + |
3 | 10 | runs: |
4 | | - using: 'composite' |
| 11 | + using: composite |
5 | 12 | steps: |
6 | | - - name: Setup Node.js |
7 | | - uses: actions/setup-node@v4 |
| 13 | + - name: Use Node.js ${{ inputs.node-version }} |
| 14 | + uses: actions/setup-node@v3 |
8 | 15 | with: |
9 | | - node-version: 20 |
| 16 | + node-version: ${{ inputs.node-version }} |
10 | 17 | registry-url: 'https://registry.npmjs.org' |
11 | | - - name: Restore cached npm dependencies |
12 | | - id: cache-dependencies-restore |
13 | | - uses: actions/cache/restore@v4 |
| 18 | + cache: npm |
| 19 | + |
| 20 | + - name: Get npm cache directory |
| 21 | + id: npm-cache-dir |
| 22 | + shell: pwsh |
| 23 | + run: echo "dir=$(npm config get cache)" >> ${env:GITHUB_OUTPUT} |
| 24 | + |
| 25 | + - name: Cache NPM dependencies |
| 26 | + uses: actions/cache@v4 |
| 27 | + id: npm-cache # use this to check for `cache-hit` ==> if: steps.npm-cache.outputs.cache-hit != 'true' |
14 | 28 | with: |
15 | | - path: | |
16 | | - node_modules |
17 | | - ~/.cache/Cypress # needed for the Cypress binary |
18 | | - key: ${{ runner.os }}-npm-dependencies-${{ hashFiles('package-lock.json') }} |
19 | | - - name: Npm install |
20 | | - if: steps.cache-dependencies-restore.outputs.cache-hit != 'true' |
21 | | - run: npm ci |
| 29 | + path: ${{ steps.npm-cache-dir.outputs.dir }} |
| 30 | + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} |
| 31 | + restore-keys: | |
| 32 | + ${{ runner.os }}-node- |
| 33 | +
|
| 34 | + - name: Install Dependencies |
22 | 35 | shell: bash |
23 | | - - name: Cache npm dependencies |
24 | | - id: cache-dependencies-save |
25 | | - uses: actions/cache/save@v4 |
26 | | - with: |
27 | | - path: | |
28 | | - node_modules |
29 | | - ~/.cache/Cypress # needed for the Cypress binary |
30 | | - key: ${{ steps.cache-dependencies-restore.outputs.cache-primary-key }} |
31 | | - - name: Derive appropriate SHAs for base and head for `nx affected` commands |
32 | | - uses: nrwl/nx-set-shas@v4 |
33 | | - with: |
34 | | - main-branch-name: "master" |
| 36 | + run: npm ci |
0 commit comments