File tree Expand file tree Collapse file tree
actions/setup-node-from-nvmrc Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # Setup Node.js from .nvmrc
2+
3+ A reusable composite action that sets up Node.js using the version specified in an ` .nvmrc ` file.
4+
5+ ## Usage
6+
7+ ``` yaml
8+ steps :
9+ - uses : actions/checkout@v2
10+ - name : Setup Node.js from .nvmrc
11+ uses : ./actions/setup-node-from-nvmrc
12+ ` ` `
13+
14+ ## Requirements
15+
16+ - The repository must have an ` .nvmrc` file in the root directory
17+ - The `.nvmrc` file should contain a valid Node.js version (e.g., `16.14.0`, `18.x`)
18+
19+ # # What it does
20+
21+ 1. Reads the Node.js version from the `.nvmrc` file
22+ 2. Sets up Node.js with the specified version using `actions/setup-node@v2`
23+
24+ # # Benefits
25+
26+ - Centralizes Node.js version management in `.nvmrc`
27+ - Eliminates duplicated setup code across workflows
28+ - Uses modern GitHub Actions output syntax (`$GITHUB_OUTPUT`)
Original file line number Diff line number Diff line change 1+ name : ' Setup Node.js from .nvmrc'
2+ description : ' Sets up Node.js using the version specified in .nvmrc file'
3+ runs :
4+ using : " composite"
5+ steps :
6+ - name : Get Node.js version
7+ id : nvm
8+ shell : bash
9+ run : echo "NODE_VERSION=$(cat .nvmrc)" >> $GITHUB_OUTPUT
10+ - name : Setup Node.js
11+ uses : actions/setup-node@v2
12+ with :
13+ node-version : ${{ steps.nvm.outputs.NODE_VERSION }}
Original file line number Diff line number Diff line change 1515 steps :
1616 - uses : actions/checkout@v2
1717 - name : Use Node.js ${{ matrix.node-version }}
18- uses : actions/setup-node@v1
18+ uses : actions/setup-node@v2
1919 with :
2020 node-version : ${{ matrix.node-version }}
2121 - run : yarn --frozen-lockfile --ignore-scripts
Original file line number Diff line number Diff line change 2929 # We check out the specified branch, which will be used as the base
3030 # branch for all git operations and the release PR.
3131 ref : ${{ github.event.inputs.base-branch }}
32- - name : Get Node.js version
33- id : nvm
34- run : echo ::set-output name=NODE_VERSION::$(cat .nvmrc)
35- - uses : actions/setup-node@v2
36- with :
37- node-version : ${{ steps.nvm.outputs.NODE_VERSION }}
32+ - name : Setup Node.js from .nvmrc
33+ uses : ./actions/setup-node-from-nvmrc
3834 - uses : MetaMask/action-create-release-pr@v1
3935 env :
4036 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
Original file line number Diff line number Diff line change 1414 runs-on : ubuntu-latest
1515 steps :
1616 - uses : actions/checkout@v2
17- - name : Get Node.js version
18- id : nvm
19- run : echo ::set-output name=NODE_VERSION::$(cat .nvmrc)
20- - uses : actions/setup-node@v2
21- with :
22- node-version : ${{ steps.nvm.outputs.NODE_VERSION }}
17+ - name : Setup Node.js from .nvmrc
18+ uses : ./actions/setup-node-from-nvmrc
2319 - uses : MetaMask/action-publish-release@v1
2420 env :
2521 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
You can’t perform that action at this time.
0 commit comments