Skip to content

Commit c427dbe

Browse files
Update workflows to use MetaMask/action-checkout-and-setup (#33)
This updates all workflows to use `MetaMask/action-checkout-and-setup`. --------- Co-authored-by: Frederik Bolding <[email protected]>
1 parent 06ec105 commit c427dbe

File tree

6 files changed

+106
-101
lines changed

6 files changed

+106
-101
lines changed

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

Lines changed: 38 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,30 @@ jobs:
77
prepare:
88
name: Prepare
99
runs-on: ubuntu-latest
10+
strategy:
11+
matrix:
12+
node-version: [18.x, 20.x, 22.x]
1013
steps:
11-
- uses: actions/checkout@v4
12-
- name: Use Node.js
13-
uses: actions/setup-node@v4
14+
- name: Checkout and setup environment
15+
uses: MetaMask/action-checkout-and-setup@v1
1416
with:
15-
node-version-file: '.nvmrc'
16-
cache: 'yarn'
17-
- name: Install Yarn dependencies
18-
run: yarn --immutable
17+
is-high-risk-environment: false
18+
node-version: ${{ matrix.node-version }}
19+
cache-node-modules: ${{ matrix.node-version == '22.x' }}
1920

2021
build:
2122
name: Build
23+
needs: prepare
2224
runs-on: ubuntu-latest
23-
needs:
24-
- prepare
25+
strategy:
26+
matrix:
27+
node-version: [22.x]
2528
steps:
26-
- uses: actions/checkout@v4
27-
- name: Use Node.js
28-
uses: actions/setup-node@v4
29+
- name: Checkout and setup environment
30+
uses: MetaMask/action-checkout-and-setup@v1
2931
with:
30-
node-version-file: '.nvmrc'
31-
cache: 'yarn'
32-
- run: yarn --immutable --immutable-cache
32+
is-high-risk-environment: false
33+
node-version: ${{ matrix.node-version }}
3334
- run: yarn build
3435
- name: Require clean working directory
3536
shell: bash
@@ -41,17 +42,17 @@ jobs:
4142
4243
lint:
4344
name: Lint
45+
needs: prepare
4446
runs-on: ubuntu-latest
45-
needs:
46-
- prepare
47+
strategy:
48+
matrix:
49+
node-version: [22.x]
4750
steps:
48-
- uses: actions/checkout@v4
49-
- name: Use Node.js
50-
uses: actions/setup-node@v4
51+
- name: Checkout and setup environment
52+
uses: MetaMask/action-checkout-and-setup@v1
5153
with:
52-
node-version-file: '.nvmrc'
53-
cache: 'yarn'
54-
- run: yarn --immutable --immutable-cache
54+
is-high-risk-environment: false
55+
node-version: ${{ matrix.node-version }}
5556
- run: yarn lint
5657
- name: Validate RC changelog
5758
if: ${{ startsWith(github.head_ref, 'release/') }}
@@ -69,20 +70,17 @@ jobs:
6970
7071
test:
7172
name: Test
73+
needs: prepare
7274
runs-on: ubuntu-latest
73-
needs:
74-
- prepare
7575
strategy:
7676
matrix:
77-
node-version: [18.x, 20.x]
77+
node-version: [18.x, 20.x, 22.x]
7878
steps:
79-
- uses: actions/checkout@v4
80-
- name: Use Node.js ${{ matrix.node-version }}
81-
uses: actions/setup-node@v4
79+
- name: Checkout and setup environment
80+
uses: MetaMask/action-checkout-and-setup@v1
8281
with:
82+
is-high-risk-environment: false
8383
node-version: ${{ matrix.node-version }}
84-
cache: 'yarn'
85-
- run: yarn --immutable --immutable-cache
8684
- run: yarn test
8785
- name: Require clean working directory
8886
shell: bash
@@ -94,25 +92,25 @@ jobs:
9492
9593
compatibility-test:
9694
name: Compatibility test
95+
needs: prepare
9796
runs-on: ubuntu-latest
98-
needs:
99-
- prepare
10097
strategy:
10198
matrix:
102-
node-version: [18.x, 20.x]
99+
node-version: [18.x, 20.x, 22.x]
103100
steps:
104-
- uses: actions/checkout@v4
105-
- name: Use Node.js ${{ matrix.node-version }}
106-
uses: actions/setup-node@v4
101+
- name: Checkout and setup environment
102+
uses: MetaMask/action-checkout-and-setup@v1
107103
with:
104+
is-high-risk-environment: false
108105
node-version: ${{ matrix.node-version }}
109-
cache: 'yarn'
110-
- run: rm yarn.lock && YARN_ENABLE_IMMUTABLE_INSTALLS=false yarn
106+
- name: Install dependencies via Yarn
107+
run: rm yarn.lock && YARN_ENABLE_IMMUTABLE_INSTALLS=false yarn
111108
- run: yarn test
109+
- name: Restore lockfile
110+
run: git restore yarn.lock
112111
- name: Require clean working directory
113112
shell: bash
114113
run: |
115-
git restore yarn.lock
116114
if ! git diff --exit-code; then
117115
echo "Working tree dirty at end of job"
118116
exit 1

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

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,22 @@ 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: Setup Node.js
33-
uses: actions/setup-node@v4
34-
with:
35-
node-version-file: '.nvmrc'
36-
- uses: MetaMask/action-create-release-pr@v3
37-
env:
38-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36+
37+
- uses: MetaMask/action-create-release-pr@v4
3938
with:
4039
release-type: ${{ github.event.inputs.release-type }}
4140
release-version: ${{ github.event.inputs.release-version }}
41+
env:
42+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/main.yml

Lines changed: 17 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
@@ -19,6 +22,18 @@ jobs:
1922
run: ${{ steps.download-actionlint.outputs.executable }} -color
2023
shell: bash
2124

25+
analyse-code:
26+
name: Code scanner
27+
needs: check-workflows
28+
uses: ./.github/workflows/security-code-scanner.yml
29+
permissions:
30+
actions: read
31+
contents: read
32+
security-events: write
33+
secrets:
34+
SECURITY_SCAN_METRICS_TOKEN: ${{ secrets.SECURITY_SCAN_METRICS_TOKEN }}
35+
APPSEC_BOT_SLACK_WEBHOOK: ${{ secrets.APPSEC_BOT_SLACK_WEBHOOK }}
36+
2237
build-lint-test:
2338
name: Build, lint, and test
2439
uses: ./.github/workflows/build-lint-test.yml
@@ -28,6 +43,7 @@ jobs:
2843
runs-on: ubuntu-latest
2944
needs:
3045
- check-workflows
46+
- analyse-code
3147
- build-lint-test
3248
outputs:
3349
PASSED: ${{ steps.set-output.outputs.PASSED }}

.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-
- name: Checkout the repository
25-
uses: actions/checkout@v4
26-
- name: Use Node.js
27-
uses: actions/setup-node@v4
24+
- name: Checkout and setup environment
25+
uses: MetaMask/action-checkout-and-setup@v1
2826
with:
29-
node-version-file: '.nvmrc'
30-
cache: 'yarn'
31-
- name: Install npm dependencies
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: 29 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -9,75 +9,69 @@ on:
99
required: true
1010
PUBLISH_DOCS_TOKEN:
1111
required: true
12-
1312
jobs:
1413
publish-release:
1514
permissions:
1615
contents: write
1716
runs-on: ubuntu-latest
1817
steps:
19-
- uses: actions/checkout@v4
18+
- name: Checkout and setup environment
19+
uses: MetaMask/action-checkout-and-setup@v1
2020
with:
21+
is-high-risk-environment: true
2122
ref: ${{ github.sha }}
22-
- name: Setup Node.js
23-
uses: actions/setup-node@v4
24-
with:
25-
node-version-file: '.nvmrc'
2623
- uses: MetaMask/action-publish-release@v3
2724
env:
2825
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29-
- name: Install
30-
run: |
31-
yarn install
32-
yarn build
33-
- uses: actions/cache@v3
34-
id: restore-build
26+
- run: yarn build
27+
- name: Upload build artifacts
28+
uses: actions/upload-artifact@v4
3529
with:
30+
name: publish-release-artifacts-${{ github.sha }}
31+
retention-days: 4
32+
include-hidden-files: true
3633
path: |
3734
./dist
3835
./node_modules/.yarn-state.yml
39-
key: ${{ github.sha }}
4036
4137
publish-npm-dry-run:
42-
runs-on: ubuntu-latest
4338
needs: publish-release
39+
runs-on: ubuntu-latest
4440
steps:
45-
- uses: actions/checkout@v4
41+
- name: Checkout and setup environment
42+
uses: MetaMask/action-checkout-and-setup@v1
4643
with:
44+
is-high-risk-environment: true
4745
ref: ${{ github.sha }}
48-
- uses: actions/cache@v3
49-
id: restore-build
46+
- name: Restore build artifacts
47+
uses: actions/download-artifact@v4
5048
with:
51-
path: |
52-
./dist
53-
./node_modules/.yarn-state.yml
54-
key: ${{ github.sha }}
49+
name: publish-release-artifacts-${{ github.sha }}
5550
- name: Dry Run Publish
5651
# omit npm-token token to perform dry run publish
57-
uses: MetaMask/action-npm-publish@v4
52+
uses: MetaMask/action-npm-publish@v5
5853
with:
5954
slack-webhook-url: ${{ secrets.SLACK_WEBHOOK_URL }}
6055
subteam: S042S7RE4AE # @metamask-npm-publishers
6156
env:
6257
SKIP_PREPACK: true
6358

6459
publish-npm:
65-
environment: npm-publish
66-
runs-on: ubuntu-latest
6760
needs: publish-npm-dry-run
61+
runs-on: ubuntu-latest
62+
environment: npm-publish
6863
steps:
69-
- uses: actions/checkout@v4
64+
- name: Checkout and setup environment
65+
uses: MetaMask/action-checkout-and-setup@v1
7066
with:
67+
is-high-risk-environment: true
7168
ref: ${{ github.sha }}
72-
- uses: actions/cache@v3
73-
id: restore-build
69+
- name: Restore build artifacts
70+
uses: actions/download-artifact@v4
7471
with:
75-
path: |
76-
./dist
77-
./node_modules/.yarn-state.yml
78-
key: ${{ github.sha }}
72+
name: publish-release-artifacts-${{ github.sha }}
7973
- name: Publish
80-
uses: MetaMask/action-npm-publish@v2
74+
uses: MetaMask/action-npm-publish@v5
8175
with:
8276
# This `NPM_TOKEN` needs to be manually set per-repository.
8377
# Look in the repository settings under "Environments", and set this token in the `npm-publish` environment.
@@ -86,8 +80,8 @@ jobs:
8680
SKIP_PREPACK: true
8781

8882
get-release-version:
89-
runs-on: ubuntu-latest
9083
needs: publish-npm
84+
runs-on: ubuntu-latest
9185
outputs:
9286
RELEASE_VERSION: ${{ steps.get-release-version.outputs.RELEASE_VERSION }}
9387
steps:
@@ -99,8 +93,8 @@ jobs:
9993
run: ./scripts/get.sh ".version" "RELEASE_VERSION"
10094

10195
publish-release-to-gh-pages:
102-
needs: get-release-version
10396
name: Publish docs to `${{ needs.get-release-version.outputs.RELEASE_VERSION }}` directory of `gh-pages` branch
97+
needs: get-release-version
10498
permissions:
10599
contents: write
106100
uses: ./.github/workflows/publish-docs.yml
@@ -110,8 +104,8 @@ jobs:
110104
PUBLISH_DOCS_TOKEN: ${{ secrets.PUBLISH_DOCS_TOKEN }}
111105

112106
publish-release-to-latest-gh-pages:
113-
needs: publish-npm
114107
name: Publish docs to `latest` directory of `gh-pages` branch
108+
needs: publish-npm
115109
permissions:
116110
contents: write
117111
uses: ./.github/workflows/publish-docs.yml

.github/workflows/security-code-scanner.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
11
name: MetaMask Security Code Scanner
22

33
on:
4-
push:
5-
branches:
6-
- main
7-
pull_request:
8-
branches:
9-
- main
4+
workflow_call:
5+
secrets:
6+
SECURITY_SCAN_METRICS_TOKEN:
7+
required: false
8+
APPSEC_BOT_SLACK_WEBHOOK:
9+
required: false
1010
workflow_dispatch:
1111

1212
jobs:
1313
run-security-scan:
14+
name: Run security scan
1415
runs-on: ubuntu-latest
1516
permissions:
1617
actions: read
1718
contents: read
1819
security-events: write
1920
steps:
20-
- name: MetaMask Security Code Scanner
21+
- name: Analyse code
2122
uses: MetaMask/action-security-code-scanner@v1
2223
with:
2324
repo: ${{ github.repository }}

0 commit comments

Comments
 (0)