How to specify which Node version to use in Github Actions
- By : Mydatahack
- Category : Git, Infrastructure
- Tags: CICD, Github Actions, Node.js
When you want to specify which Node version to use in your Github Actions, you can use actions/setup-node@v2.
The alternative way is to use a node container.
When you try to use a publicly available node container like runs-on: node:alpine-xx, the pipeline gets stuck in a queue. runs-on is not for a container name. It’s for a virtual machine hosted by GitHub and the best option for a Linux machine at the moment is ubuntu-latest.
In fact, GitHub supports runners for Ubuntu Linux (ubuntu-latest), Mac (mac-latest) and Windows (windows-latest). You can see other supported virtual environments here.
Instead of adding a container name in runs-on, we can add container: [image-name]. Then the jobs will be run on the specified container.