Skip to content

Commit 08146dd

Browse files
committed
fix(ci): installing dependencies from the cache
1 parent 71f7f67 commit 08146dd

File tree

1 file changed

+32
-11
lines changed

1 file changed

+32
-11
lines changed

.github/workflows/main.yml

+32-11
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,47 @@
11
name: CI
2-
on: [push]
3-
jobs:
4-
build:
5-
name: Build, lint, and test on Node ${{ matrix.node }} and ${{ matrix.os }}
62

3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
# Allows to run this workflow manually from the Actions tab
10+
workflow_dispatch:
11+
12+
jobs:
13+
ci:
14+
name: CI on Node ${{ matrix.node }} and ${{ matrix.os }}
715
runs-on: ${{ matrix.os }}
816
strategy:
917
matrix:
10-
node: ['12.x', '14.x']
11-
os: [ubuntu-latest, windows-latest, macOS-latest]
18+
node-version: ['12.x', '14.x', '16.x']
19+
os: [ubuntu-latest]
1220

1321
steps:
1422
- name: Checkout repo
1523
uses: actions/checkout@v2
1624

17-
- name: Use Node ${{ matrix.node }}
18-
uses: actions/setup-node@v1
25+
- name: Install Node ${{ matrix.node-version }}
26+
uses: actions/setup-node@v2
27+
with:
28+
node-version: ${{ matrix.node-version }}
29+
30+
# See: https://github.com/actions/cache/blob/main/examples.md#node---yarn
31+
- name: Get Yarn cache directory
32+
id: yarn-cache-dir-path
33+
run: echo "::set-output name=dir::$(yarn cache dir)"
34+
35+
- name: Use Yarn cache
36+
uses: actions/cache@v2
37+
id: yarn-cache
1938
with:
20-
node-version: ${{ matrix.node }}
39+
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
40+
key: ${{ matrix.os }}-yarn-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
2141

22-
- name: Install deps and build (with cache)
23-
uses: bahmutov/npm-install@v1
42+
- name: Install dependencies
43+
# `--prefer-offline` gives local cache the priority to restore
44+
run: yarn install --prefer-offline --frozen-lockfile
2445

2546
- name: Lint
2647
run: yarn lint

0 commit comments

Comments
 (0)