使用CircleCI部署到Firebase托pipe

我试图找出如何使用CircleCI部署到Firebase托pipe。 据我所知,没有办法用SSH密钥设置部署,所以我试图find在部署过程中login到Firebase的方法,并推送代码。 我到目前为止所尝试的是我的circle.yml中的以下内容:

// circle.yml deployment: production: branch: circle-deploy commands: - npm install -g firebase-tools - firebase login | echo -e "${FIREBASE_EMAIL}\n${FIREBASE_PASSWORD}" - firebase deploy 

但是,我不断收到以下错误,我不知道如何补救。

 stream.js:94 throw er; // Unhandled stream error in pipe. ^ Error: write EPIPE at errnoException (net.js:904:11) at Object.afterWrite (net.js:720:19) 

我只需要做到这一点,有一个更简单的方法

  1. 在你的机器上,你可以input你的访问令牌

     firebase login:ci 
  2. 将该标记另存为circleci中的环境variables$FIREBASE_TOKEN
  3. 对于您的部署步骤,您可以跳过login:

     deployment: production: branch: master commands: - firebase deploy --token=$FIREBASE_TOKEN --non-interactive 

对于任何人在这个问题上磕磕绊绊,这些是我必须采取的步骤,以获得使用Firebase托pipe的CircleCI(以及其他CI)。

  1. 生成一个CI令牌: firebase login:ci
  2. 将该标记另存为ENV var( FIREBASE_TOKEN
  3. 在部署脚本中使用标记: firebase deploy --token=$FIREBASE_TOKEN --non-interactive

Firebase最近添加了login:ci来防止人们使用CI服务的个人部署令牌。

上面的其他答案的一小部分…

为了避免在每个版本中在全球范围内安装firebase-tools:

修改你的package.json文件,把firebase-tools作为一个dev依赖项包含进去:

 npm install --save-dev firebase-tools 

然后在你的circle.yml文件中:

 deployment: production: branch: master commands: - ./node_modules/.bin/firebase deploy --token=$FIREBASE_TOKEN --non-interactive 

以下是我们遵循的部署到CircleCi的过程。

  1. 将您的用户名和密码作为环境variables存储在CircleCi中的项目级别。

  2. 编辑你的circle.yml

     deployment: production: branch: your_branch commands: - npm install -g firebase-tools - firebase login --email $FIREBASE_USERNAME --password $FIREBASE_PASSWORD - firebase deploy 
  3. 推送到你的分支

似乎工作正常。

这是我的初始设置,只部署主站,跳过testing

  1. 在本地机器上运行npm install -g firebase-tools
  2. 运行firebaselogin:ci在您的本地机器上获取令牌
  3. 运行firebase初始化。 这将创buildfirebase.json确保它已经提交
  4. 在circileci项目的BUILD SETTINGS中的环境variables中configurationFIREBASE_TOKEN

//circle.yml

 general: branches: only: - master test: override: - echo "test" deployment: production: branch: master commands: - npm install -g firebase-tools - firebase deploy --token=$FIREBASE_TOKEN --non-interactive