-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support .nvmrc #32
Comments
I think its probably unlikely we're going to expand our expression parsing to that degree - in general computation isn't supposed to happen there and we want to discourage moving in that direction, and keep that more towards just reading existing variables. Note that you could do something like the following here:
I'm interested in this option. We're looking at doing something similar in setup-dotnet: actions/setup-dotnet#15. I see a couple options here:
@chrispat, any thoughts on this one? I think maybe we should establish a pattern here and with setup-dotnet for similar requests (I'm sure node and dotnet aren't the only tools with config files that can specify versions). |
Thanks for the tip* about just using an output, that makes sense and is good enough for me, though the simpler developer experience would be nice. |
I tried to do this and it seems to be treating the environment variable as a literal instead of getting its value. Here's the error and my config:
- name: Read .nvmrc
run: NVMRC=$(cat .nvmrc)
- name: Use Node.js (.nvmrc)
uses: actions/setup-node@v1
with:
node-version: ${NVMRC} |
Sorry, had a lapse when I wrote this. Try changing your workflow to:
Env variables are scoped to a given step so they don't automatically carry over, but we can use outputs instead. |
@damccorm That worked thank you! |
if it's helpful in making the decision, travis-ci has the behavior of 1. and is very often sufficient for my projects. it also has the benefit of removing the need to keep the versions in sync for what is intended for use with local development and the version intended for CI since there is a single source of truth rather than distributing across multiple files. |
The following also works well. - name: Read .nvmrc
run: echo ::set-output name=NVMRC::$(cat .nvmrc)
id: nvm
- name: Setup node
uses: actions/setup-node@v1
with:
node-version: '${{ steps.nvm.outputs.NVMRC }}' |
Has there been any progress towards natively supporting .nvmrc instead of having to use |
We got the following issue in the virtual environments repo: actions/runner-images#4 What's the latest on the plans to support .nvmrc? Is it on the roadmap? |
I think the action could be updated to support .nvmrc as the default if no version is specified in the |
I chatted with @bryanmacfarlane about this. I think for now we're going to close this issue, and instead move forward with the recommendation to just add nvm to the image as is requested in the virtual environments repo. actions/runner-images#4 |
If you're not already using nvm under the hood to install node versions... Why add another dependency to the mix? In any case
works, it's just really wordy to have to put it everywhere |
Yeah, pretty straight forward and we haven't closed so we'll get to it at some point. Note that in your example above you should add |
Wait, this is not supported yet? Well, good to know now 🤷🏻♂️ |
Update/Add nvm · Issue #4 · actions/virtual-environments was closed and |
I'm so happy about this. |
Awesome! How can we know once it's deployed and we can remove custom actions we had to support nvm? Thanks 🙏 |
Yet another variation. 👇 I guess no real advantages or disadvantages though. - name: Read .nvmrc
run: echo NVMRC=`cat .nvmrc` >> $GITHUB_ENV
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: ${{ env.NVMRC }} |
- Set `.nvmrc` value to `with.node-version` See <actions/setup-node#32 (comment)> - Add `npm run lint-ci` to use "Problem Matchers" of actions/setup-node
- Set `.nvmrc` value to `with.node-version` See <actions/setup-node#32 (comment)> - Add `npm run lint-ci` to use "Problem Matchers" of actions/setup-node
Is this fixed with #338? |
I declare it fixed! I didn't say it, I declared it |
If you got here from googling, let me tell you, that the newest and simplest way of reading the - name: Setup node
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc' |
…e` can read node version from `.nvmrc` file directly cf actions/setup-node#32 (comment)
* Replace use of `::set-output` as explained in https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/, before they are disabled. * upgrade most actions (except `actions/cache`) * upgrade `actions/setup-node@v2.2.0` --> `actions/setup-node@v3` * get rid of `browniebroke/read-nvmrc-action`, since `actions/setup-node` can read node version from `.nvmrc` file directly cf actions/setup-node#32 (comment)
DEVPOPS-813 : Create sandbox fromRules must require fromProperty in the Sandbox CLI
I recently added this to my action and publishing started failing. I'm still trying to understand if this is the root cause, but I believe that setting |
It would be nice if
setup-node
understood an .nvmrc file (even if it does not use nvm under the hood, the idea is thenode-version
is just the contents of the file).If GitHub Actions as a whole could read the contents of a file as part of an expression, I could do something like
But I don't know where to log that type of feature request!
Perhaps '.nvmrc' could be used as a special placeholder, so that:
Instructs this action to read the contents and treat the contents as the desired version?
The text was updated successfully, but these errors were encountered: