Skip to content

Commit 1a318ef

Browse files
committed
ci(node setup): update node-based gh actions
1 parent 61005b7 commit 1a318ef

File tree

5 files changed

+58
-98
lines changed

5 files changed

+58
-98
lines changed

.github/actions/setup/action.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Setup node and pnpm
2+
description: |
3+
Configures Node, pnpm, cache, performs pnpm install
4+
5+
inputs:
6+
pnpm-run-install:
7+
description: Whether to run pnpm install
8+
required: false
9+
default: "true"
10+
pnpm-restore-cache:
11+
description: Whether to restore cache
12+
required: false
13+
default: "true"
14+
pnpm-install-cache-key:
15+
description: The cache key for the pnpm install cache
16+
required: false
17+
default: ${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
18+
19+
runs:
20+
using: composite
21+
steps:
22+
- name: Install pnpm
23+
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0
24+
with:
25+
run_install: false
26+
27+
- name: Restore pnpm install cache
28+
if: ${{ inputs.pnpm-restore-cache == 'true' }}
29+
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
30+
with:
31+
# See here for caching with `yarn` https://github.com/actions/cache/blob/main/examples.md#node---yarn or you can leverage caching with actions/setup-node https://github.com/actions/setup-node
32+
path: |
33+
~/.pnpm-store
34+
${{ github.workspace }}/.next/cache
35+
# Generate a new cache whenever packages or source files change.
36+
key: ${{ inputs.pnpm-install-cache-key }}
37+
# If source files changed but packages didn't, rebuild from a prior cache.
38+
restore-keys: |
39+
${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-
40+
41+
- name: Run pnpm install
42+
if: ${{ inputs.pnpm-run-install == 'true' }}
43+
shell: bash
44+
run: pnpm install --frozen-lockfile
45+
46+
- name: Setup Node.js
47+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
48+
with:
49+
node-version-file: ".nvmrc"
50+
cache: "pnpm"

.github/workflows/build.yml

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -26,32 +26,8 @@ jobs:
2626
with:
2727
persist-credentials: false
2828

29-
- name: Install pnpm
30-
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0
31-
with:
32-
run_install: false
33-
34-
- uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
35-
with:
36-
# See here for caching with `yarn` https://github.com/actions/cache/blob/main/examples.md#node---yarn or you can leverage caching with actions/setup-node https://github.com/actions/setup-node
37-
path: |
38-
~/.pnpm-store
39-
${{ github.workspace }}/.next/cache
40-
# Generate a new cache whenever packages or source files change.
41-
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
42-
# If source files changed but packages didn't, rebuild from a prior cache.
43-
restore-keys: |
44-
${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-
45-
46-
- name: Set up Node.js
47-
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
48-
with:
49-
# We want to ensure that the Node.js version running here respects our supported versions
50-
node-version-file: ".nvmrc"
51-
cache: "pnpm"
52-
53-
- name: Install dependencies
54-
run: pnpm install --frozen-lockfile
29+
- name: Node setup
30+
uses: ./.github/actions/setup
5531

5632
- name: Build check
5733
run: pnpm build

.github/workflows/format.yml

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -26,30 +26,8 @@ jobs:
2626
with:
2727
persist-credentials: false
2828

29-
- name: Install pnpm
30-
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0
31-
with:
32-
run_install: false
33-
34-
- uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
35-
with:
36-
# See here for caching with `yarn` https://github.com/actions/cache/blob/main/examples.md#node---yarn or you can leverage caching with actions/setup-node https://github.com/actions/setup-node
37-
path: .next/cache
38-
# Generate a new cache whenever packages or source files change.
39-
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
40-
# If source files changed but packages didn't, rebuild from a prior cache.
41-
restore-keys: |
42-
${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-
43-
44-
- name: Set up Node.js
45-
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
46-
with:
47-
# We want to ensure that the Node.js version running here respects our supported versions
48-
node-version-file: ".nvmrc"
49-
cache: "pnpm"
50-
51-
- name: Install dependencies
52-
run: pnpm install --frozen-lockfile
29+
- name: Node setup
30+
uses: ./.github/actions/setup
5331

5432
- name: Format check
5533
run: pnpm fmt.check

.github/workflows/lint.yml

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -26,30 +26,8 @@ jobs:
2626
with:
2727
persist-credentials: false
2828

29-
- name: Install pnpm
30-
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0
31-
with:
32-
run_install: false
33-
34-
- uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
35-
with:
36-
# See here for caching with `yarn` https://github.com/actions/cache/blob/main/examples.md#node---yarn or you can leverage caching with actions/setup-node https://github.com/actions/setup-node
37-
path: .next/cache
38-
# Generate a new cache whenever packages or source files change.
39-
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
40-
# If source files changed but packages didn't, rebuild from a prior cache.
41-
restore-keys: |
42-
${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-
43-
44-
- name: Set up Node.js
45-
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
46-
with:
47-
# We want to ensure that the Node.js version running here respects our supported versions
48-
node-version-file: ".nvmrc"
49-
cache: "pnpm"
50-
51-
- name: Install dependencies
52-
run: pnpm install --frozen-lockfile
29+
- name: Node setup
30+
uses: ./.github/actions/setup
5331

5432
- name: Lint check
5533
run: pnpm lint

.github/workflows/unit-testing.yml

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -26,30 +26,8 @@ jobs:
2626
with:
2727
persist-credentials: false
2828

29-
- name: Install pnpm
30-
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0
31-
with:
32-
run_install: false
33-
34-
- uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
35-
with:
36-
# See here for caching with `yarn` https://github.com/actions/cache/blob/main/examples.md#node---yarn or you can leverage caching with actions/setup-node https://github.com/actions/setup-node
37-
path: .next/cache
38-
# Generate a new cache whenever packages or source files change.
39-
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
40-
# If source files changed but packages didn't, rebuild from a prior cache.
41-
restore-keys: |
42-
${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-
43-
44-
- name: Set up Node.js
45-
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
46-
with:
47-
# We want to ensure that the Node.js version running here respects our supported versions
48-
node-version-file: ".nvmrc"
49-
cache: "pnpm"
50-
51-
- name: Install dependencies
52-
run: pnpm install --frozen-lockfile
29+
- name: Node setup
30+
uses: ./.github/actions/setup
5331

5432
- name: Unit tests
5533
run: pnpm test --coverage

0 commit comments

Comments
 (0)