Skip to content

Commit 7e61f40

Browse files
authored
Implement MetaMask/action-checkout-and-setup (#262)
* Implement `MetaMask/action-checkout-and-setup` * Update version to v1 * Only cache node_modules for one Node version * Add `node-version` option * Add name to jobs
1 parent 54b8c11 commit 7e61f40

File tree

5 files changed

+40
-95
lines changed

5 files changed

+40
-95
lines changed

.github/workflows/build-lint-test.yml

Lines changed: 16 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,12 @@ jobs:
1111
matrix:
1212
node-version: [18.x, 20.x, 22.x]
1313
steps:
14-
- uses: actions/checkout@v4
15-
- name: Install Corepack via Node
16-
uses: actions/setup-node@v4
17-
with:
18-
node-version-file: '.nvmrc'
19-
- name: Install Yarn
20-
run: corepack enable
21-
- name: Install Node.js ${{ matrix.node-version }} and restore Yarn cache
22-
uses: actions/setup-node@v4
14+
- name: Checkout and setup environment
15+
uses: MetaMask/action-checkout-and-setup@v1
2316
with:
17+
is-high-risk-environment: false
2418
node-version: ${{ matrix.node-version }}
25-
cache: 'yarn'
26-
- name: Install dependencies via Yarn
27-
run: yarn --immutable
19+
cache-node-modules: ${{ matrix.node-version == '22.x' }}
2820

2921
build:
3022
name: Build
@@ -34,20 +26,11 @@ jobs:
3426
matrix:
3527
node-version: [22.x]
3628
steps:
37-
- uses: actions/checkout@v4
38-
- name: Install Corepack via Node
39-
uses: actions/setup-node@v4
40-
with:
41-
node-version-file: '.nvmrc'
42-
- name: Install Yarn
43-
run: corepack enable
44-
- name: Install Node.js ${{ matrix.node-version }} and restore Yarn cache
45-
uses: actions/setup-node@v4
29+
- name: Checkout and setup environment
30+
uses: MetaMask/action-checkout-and-setup@v1
4631
with:
32+
is-high-risk-environment: false
4733
node-version: ${{ matrix.node-version }}
48-
cache: 'yarn'
49-
- name: Install dependencies via Yarn
50-
run: yarn --immutable --immutable-cache
5134
- run: yarn build
5235
- name: Require clean working directory
5336
shell: bash
@@ -65,20 +48,11 @@ jobs:
6548
matrix:
6649
node-version: [22.x]
6750
steps:
68-
- uses: actions/checkout@v4
69-
- name: Install Corepack via Node
70-
uses: actions/setup-node@v4
71-
with:
72-
node-version-file: '.nvmrc'
73-
- name: Install Yarn
74-
run: corepack enable
75-
- name: Install Node.js ${{ matrix.node-version }} and restore Yarn cache
76-
uses: actions/setup-node@v4
51+
- name: Checkout and setup environment
52+
uses: MetaMask/action-checkout-and-setup@v1
7753
with:
54+
is-high-risk-environment: false
7855
node-version: ${{ matrix.node-version }}
79-
cache: 'yarn'
80-
- name: Install dependencies via Yarn
81-
run: yarn --immutable --immutable-cache
8256
- run: yarn lint
8357
- name: Validate RC changelog
8458
if: ${{ startsWith(github.head_ref, 'release/') }}
@@ -102,20 +76,11 @@ jobs:
10276
matrix:
10377
node-version: [18.x, 20.x, 22.x]
10478
steps:
105-
- uses: actions/checkout@v4
106-
- name: Install Corepack via Node
107-
uses: actions/setup-node@v4
108-
with:
109-
node-version-file: '.nvmrc'
110-
- name: Install Yarn
111-
run: corepack enable
112-
- name: Install Node.js ${{ matrix.node-version }} and restore Yarn cache
113-
uses: actions/setup-node@v4
79+
- name: Checkout and setup environment
80+
uses: MetaMask/action-checkout-and-setup@v1
11481
with:
82+
is-high-risk-environment: false
11583
node-version: ${{ matrix.node-version }}
116-
cache: 'yarn'
117-
- name: Install dependencies via Yarn
118-
run: yarn --immutable --immutable-cache
11984
- run: yarn test
12085
- name: Require clean working directory
12186
shell: bash
@@ -133,18 +98,11 @@ jobs:
13398
matrix:
13499
node-version: [18.x, 20.x, 22.x]
135100
steps:
136-
- uses: actions/checkout@v4
137-
- name: Install Corepack via Node
138-
uses: actions/setup-node@v4
139-
with:
140-
node-version-file: '.nvmrc'
141-
- name: Install Yarn
142-
run: corepack enable
143-
- name: Install Node.js ${{ matrix.node-version }} and restore Yarn cache
144-
uses: actions/setup-node@v4
101+
- name: Checkout and setup environment
102+
uses: MetaMask/action-checkout-and-setup@v1
145103
with:
104+
is-high-risk-environment: false
146105
node-version: ${{ matrix.node-version }}
147-
cache: 'yarn'
148106
- name: Install dependencies via Yarn
149107
run: rm yarn.lock && YARN_ENABLE_IMMUTABLE_INSTALLS=false yarn
150108
- run: yarn test

.github/workflows/create-release-pr.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,19 @@ jobs:
2121
contents: write
2222
pull-requests: write
2323
steps:
24-
- uses: actions/checkout@v4
24+
- name: Checkout and setup environment
25+
uses: MetaMask/action-checkout-and-setup@v1
2526
with:
26-
# This is to guarantee that the most recent tag is fetched.
27-
# This can be configured to a more reasonable value by consumers.
27+
is-high-risk-environment: true
28+
29+
# This is to guarantee that the most recent tag is fetched. This can
30+
# be configured to a more reasonable value by consumers.
2831
fetch-depth: 0
32+
2933
# We check out the specified branch, which will be used as the base
3034
# branch for all git operations and the release PR.
3135
ref: ${{ github.event.inputs.base-branch }}
32-
- name: Install Node.js
33-
uses: actions/setup-node@v4
34-
with:
35-
node-version-file: '.nvmrc'
36+
3637
- uses: MetaMask/action-create-release-pr@v4
3738
with:
3839
release-type: ${{ github.event.inputs.release-type }}

.github/workflows/main.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ jobs:
1010
name: Check workflows
1111
runs-on: ubuntu-latest
1212
steps:
13-
- uses: actions/checkout@v4
13+
- name: Checkout and setup environment
14+
uses: MetaMask/action-checkout-and-setup@v1
15+
with:
16+
is-high-risk-environment: false
1417
- name: Download actionlint
1518
id: download-actionlint
1619
run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/7fdc9630cc360ea1a469eed64ac6d78caeda1234/scripts/download-actionlint.bash) 1.6.23

.github/workflows/publish-docs.yml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,10 @@ jobs:
2121
- name: Ensure `destination_dir` is not empty
2222
if: ${{ inputs.destination_dir == '' }}
2323
run: exit 1
24-
- uses: actions/checkout@v4
25-
- name: Install Corepack via Node
26-
uses: actions/setup-node@v4
24+
- name: Checkout and setup environment
25+
uses: MetaMask/action-checkout-and-setup@v1
2726
with:
28-
node-version-file: '.nvmrc'
29-
- name: Install Yarn
30-
run: corepack enable
31-
- name: Install dependencies via Yarn
32-
run: yarn --immutable
27+
is-high-risk-environment: true
3328
- name: Run build script
3429
run: yarn build:docs
3530
- name: Deploy to `${{ inputs.destination_dir }}` directory of `gh-pages` branch

.github/workflows/publish-release.yml

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,11 @@ jobs:
1515
contents: write
1616
runs-on: ubuntu-latest
1717
steps:
18-
- uses: actions/checkout@v4
18+
- name: Checkout and setup environment
19+
uses: MetaMask/action-checkout-and-setup@v1
1920
with:
21+
is-high-risk-environment: true
2022
ref: ${{ github.sha }}
21-
- name: Install Corepack via Node
22-
uses: actions/setup-node@v4
23-
with:
24-
node-version-file: '.nvmrc'
25-
- name: Install Yarn
26-
run: corepack enable
2723
- uses: MetaMask/action-publish-release@v3
2824
env:
2925
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -43,15 +39,11 @@ jobs:
4339
needs: publish-release
4440
runs-on: ubuntu-latest
4541
steps:
46-
- uses: actions/checkout@v4
42+
- name: Checkout and setup environment
43+
uses: MetaMask/action-checkout-and-setup@v1
4744
with:
45+
is-high-risk-environment: true
4846
ref: ${{ github.sha }}
49-
- name: Install Corepack via Node
50-
uses: actions/setup-node@v4
51-
with:
52-
node-version-file: '.nvmrc'
53-
- name: Install Yarn
54-
run: corepack enable
5547
- name: Restore build artifacts
5648
uses: actions/download-artifact@v4
5749
with:
@@ -70,15 +62,11 @@ jobs:
7062
runs-on: ubuntu-latest
7163
environment: npm-publish
7264
steps:
73-
- uses: actions/checkout@v4
65+
- name: Checkout and setup environment
66+
uses: MetaMask/action-checkout-and-setup@v1
7467
with:
68+
is-high-risk-environment: true
7569
ref: ${{ github.sha }}
76-
- name: Install Corepack via Node
77-
uses: actions/setup-node@v4
78-
with:
79-
node-version-file: '.nvmrc'
80-
- name: Install Yarn
81-
run: corepack enable
8270
- name: Restore build artifacts
8371
uses: actions/download-artifact@v4
8472
with:

0 commit comments

Comments
 (0)