How to build action with newer node versions

Currently, a javascript action is supposed to be defined with node v12:

runs:
  using: 'node12'
  main: 'index.js'

If I want to switch to a higher version, I guess the user of the action has to add an additional step to their workflow:

- uses: actions/setup-node@v2
  with:
    node-version: '14'
- uses: my-action-using-node-14

Are there any ways that we can avoid such a restriction? Can I simply write an action that states:

runs:
  using: 'node16'
  main: 'index.js'

and have it be run from a workflow as:

- uses: my-action-using-node-16

This becomes more important as v12 of nodejs is running out of time, i.e. v12 is reaching end-of-life early next year and v16 is starting active LTS today.

How can we start building actions running on versions higher than v12 without making it more difficult for our users to use our action?

1 Like