In my project, which has a folder structure as shown here:
dev-internal-web
-.firebase
-.github
-e2e
-functions
-node_modules
-src
(misc files)
I have a functions folder, which houses firebase functions. I'm looking to automate deployment of that through my actions script as shown below:
name: CI
on:
push:
branches:
- master
jobs:
hosting-deploy:
name: Deploy Hosting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions/setup-node@master
with:
node-version: '10.x'
- run: npm install
- run: npm run build
- uses: w9jds/firebase-action@master
with:
args: deploy --only hosting --project=tombstone-roleplay
env:
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
functions-deploy:
name: Deploy Functions
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: chrissank/[email protected]
env:
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
TARGET: default
The actions for the firebase hosting on the Angular project inside the folder works fine, but the second script fails with the following error:
=== Deploying to 'tombstone-roleplay'...
i deploying functions
Running command: npm --prefix "$RESOURCE_DIR" run lint
> functions@ lint /github/workspace/functions
> tslint --project tsconfig.json
sh: 1: tslint: not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! functions@ lint: `tslint --project tsconfig.json`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the functions@ lint script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?
npm ERR! A complete log of this run can be found in:
npm ERR! /github/home/.npm/_logs/2020-10-04T14_06_06_215Z-debug.log
Error: functions predeploy error: Command terminated with non-zero exit code1
After following the instructions in the comment to remove tslint and update my script to what can be found in this article: https://medium.com/mainlycoding-com/automate-firebase-functions-deployment-with-github-actions-ci-a0eb10fa308d, I received the following error:
=== Deploying to 'project-name'...
i deploying functions
Running command: npm --prefix "$RESOURCE_DIR" run lint
> functions@ lint /github/workspace/functions
> tslint --project tsconfig.json
sh: 1: tslint: not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! functions@ lint: `tslint --project tsconfig.json`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the functions@ lint script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?
npm ERR! A complete log of this run can be found in:
npm ERR! /github/home/.npm/_logs/2020-10-04T14_06_06_215Z-debug.log
Error: functions predeploy error: Command terminated with non-zero exit code1
What am I doing wrong in the "functions-deploy" section?
The
deploy
step is different to thebuild
step (different folders), so you need to runnpm install
again or bring over the deploynode_module
dependencies with your build artifact.Here is my
firebase.json
:There is some discussion over here: https://github.com/w9jds/firebase-action/issues/30
Also, ensure
tslint
,eslint
, andtsc
are in yourdevDependencies
in yourpackage.json
file.