firebase-action
firebase-action copied to clipboard
Deploying functions using node 14
For Firebase Functions, the engines in package.json
must be set to one of the supported versions, or you'll get this error:
Error: package.json in functions directory has an engines field which is unsupported. Valid choices are: {"node": "10"}, {"node":"12"}, and {"node":"14"}.
I have some function running on the node v14 runtime with a predeploy
hook in firebase.json
. Because this action runs on node 12, I get this error:
error package-name@: The engine "node" is incompatible with this module. Expected version "14". Got "12.18.1"
If you'd be open to it, I can prepare a PR with roughly these changes:
build-publish.yaml
jobs:
build:
name: docker build & push
runs-on: ubuntu-latest
+ strategy:
+ matrix:
+ node-version: [10, 12, 14]
steps:
- name: checkout scm
uses: actions/checkout@v2
- name: docker/build-push
uses: docker/build-push-action@v1
with:
username: w9jds
password: ${{ secrets.DOCKER_PASSWORD }}
repository: w9jds/firebase-action
+ build_args: version=${{ matrix.node-version }}
- tags: latest
+ tags: ${{ matrix.node-version }}
Dockerfile
- FROM node:12.18.1-alpine
+ ARG version
+ FROM node:$version-alpine
action.yaml
+ inputs:
+ node-version:
+ description: Docker version to use (alpine)
+ default: 12
runs:
using: 'docker'
- image: 'docker://w9jds/firebase-action:latest'
+ image: 'docker://w9jds/firebase-action:${{ inputs.node-version }}'
The proposed solution doesn't seem to work because ${{ inputs.node-version }}
is not evaluated in the runs.image
context. 😞
I'm testing this on a fork here: https://github.com/hongaar/firebase-action/commit/bb149a96769f1f147c699ed3852e08b91bbdb271
Not sure if using image: Dockerfile
instead would solve this. --build-args
is not supported and this has the added downside of having to build the image on each action run.
Edit Alternative could be to create different branches/tags for each node version.
Yes, I looked into this quite awhile ago and found that --build-args
wasn't supported and open a forum thread about it in the GitHub actions area but never got anyone to respond if they will ever add them. I used to build on each action, but was requested to change it to a pre-build image to reduce built times.
FWIW, Im able to set the node version using another action in my step like so
- uses: actions/setup-node@v2-beta
with:
node-version: '14'
setup-node
is a typescript action, not a docker action. Like stated above this is a pre-compiled container action meaning we are more limited on what can be sent in. Unless I spend time installing Node on every run this isn't really doable. Even less so now that the action no longer builds every run it pulls an already created image.
I have been looking into changing this to allow it to install Node and JDK on each run but that would greatly increase run of the action again.
So I have been looking into creating a second version of this action called setup-firebase that is a JavaScript action that would work very similar to how setup-node works above. Which would ultimately setup the step in your job with your specified version of firebase-tools and node. Not sure if that is interesting to anyone, as I built it but haven't been able to test it quite yet.
So good news on this. I was able to actually support custom node and java via the above suggested setup-node
. I have created a whole new version of firebase-action here: https://github.com/w9jds/setup-firebase with the same principle. This allows you to setup the CLI and use it in the job, instead of having the action run the command for you in isolation of a container! Let me know if this covers what you were hoping for customization 😄