如何通过github操作部署firebase功能?
在我的项目中,其文件夹结构如下所示:如何通过github操作部署firebase功能?,firebase,npm,google-cloud-functions,github-actions,firebase-cli,Firebase,Npm,Google Cloud Functions,Github Actions,Firebase Cli,在我的项目中,其文件夹结构如下所示: dev-internal-web -.firebase -.github -e2e -functions -node_modules -src (misc files) 我有一个functions文件夹,其中包含firebase函数。我希望通过我的操作脚本自动部署,如下所示: name: CI on: push: branches: - master jobs: hosting-deploy: name: Deploy
dev-internal-web
-.firebase
-.github
-e2e
-functions
-node_modules
-src
(misc files)
我有一个functions文件夹,其中包含firebase函数。我希望通过我的操作脚本自动部署,如下所示:
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/deploy-firebase-functions@1.0.0
env:
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
TARGET: default
文件夹内Angular项目上firebase宿主的操作工作正常,但第二个脚本失败,出现以下错误:
=== 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
=== 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
按照注释中的说明删除tslint并将脚本更新为本文中的内容后,我收到以下错误:
=== 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
=== 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
“功能部署”部分中我做错了什么?部署步骤与构建步骤(不同的文件夹)不同,因此您需要再次运行
npm安装
,或者将部署节点单元模块
依赖项与构建工件一起提交
这是我的firebase.json
:
{
“职能”:{
“部署前”:[
“npm—前缀./functions/install”,
“npm—前缀./functions/run lint”,
“npm—前缀./functions/run build”
],
“来源”:“功能”
}
}
这里有一些讨论:
另外,确保
tslint
、eslint
和tsc
都在devdependences
的package.json
文件中。我发现了一个链接:那里有一条红色消息可以提供帮助:此包已被弃用作者消息:tslint已被弃用以支持eslint。有关详细信息,请参阅。@MrTech在尝试删除tslint后(我只是重新初始化了firebase函数,因为我还没有在那里做任何工作),现在我遇到了以下错误:npm ERR!functions@build:tsc
为了进一步说明这一点,我找到了一个详细的教程,可以帮助您@技术先生,我已经试过了,但它对我不起作用。我尝试将其添加到原始文件的末尾,但没有成功,因此我尝试了一个新文件(也没有成功)。托管没有问题,但我复制了那篇文章底部的脚本,它不起作用。进一步研究,当它不起作用时,是否有任何错误消息?