简体   繁体   English

Firebase 部署使用 Github 操作

[英]Firebase Deployment using Github Action

I'm trying to deploy my code using Github's actions to firebase.我正在尝试使用 Github 的操作将我的代码部署到 firebase。

I am receiving this error我收到此错误

    success Installed "firebase-tools@7.11.0" with binaries:
      - firebase
Done in 12.99s.
/home/runner/work/_temp/30a2b6cb-a097-4d73-ac92-5379d0cc6ccf.sh: line 2: firebase: command not found

my code for deploy is as following我的部署代码如下

deploy:
    name: Deploy
    needs: build
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Repo
        uses: actions/checkout@master
      - name: Download Artifact
        uses: actions/download-artifact@v1
        with:
          name: dist
      - name: yarn add firebase-tools
        run: |
          yarn global add firebase-tools
          firebase deploy ${{ secrets.firebase_token }} --only hosting:**** --non-interactive
        env:
          PROJECT_ID: ****

how can I add firebase-tools globally?如何在全球范围内添加 firebase-tools?

I tried https://github.com/marketplace/actions/github-action-for-firebase我试过https://github.com/marketplace/actions/github-action-for-firebase

But getting Error但得到错误

setting firebase project to ***
Now using project ***

=== Deploying to '***'...

i  deploying hosting

✔  Deploy complete!

Project Console: *******************

Error: An unexpected error has occurred.
##[error]Docker run failed with exit code 2

Here is the code for this.这是此代码。

deploy:
    name: Deploy
    needs: build
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Repo
        uses: actions/checkout@master
      - name: Download Artifact
        uses: actions/download-artifact@v1
        with:
          name: dist
      - name: Deploy to Firebase
        uses: w9jds/firebase-action@master
        with:
          args: deploy --only hosting:****
        env:
          FIREBASE_TOKEN: ${{ secrets.firebase_token }}
          PROJECT_ID: ****
Docker run failed with exit code 2

That was reported in w9jds/firebase-action issue 17这是在w9jds/firebase-action issue 17 中报道的

For me it works when I remove " --only hosting:prod ".对我来说,当我删除“ --only hosting:prod ”时它会起作用。
Probably it depends on the plan.可能这取决于计划。

You can't keep --only hosting:prod unless you have your site setup for multi-domain hosting inside of your firebase.json file and one of the sites that you can deploy is called prod .你不能让--only hosting:prod ,除非你有你的站点设置为托管您的内部多域firebase.json文件和网站,您可以部署被称为一个prod

I would recommend to follow this way!我会建议按照这种方式!

name: Build and deploy

on:
  push:
    branches: [ main ]
    
  # Run workflow manually
  workflow_dispatch:
  
jobs:
  build:
    name: Build & Deploy
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Repository
        uses: actions/checkout@main
      - name: Install dependencies
        run: npm ci
      - name: Build dependencies
        run: npm run build
      - name: Deploy to Firebase
        uses: w9jds/firebase-action@master
        with:
          args: deploy --only hosting
        env:
          FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}

You can replace npm commands with your yarn commands, and it should work fine.您可以用您的纱线命令替换 npm 命令,它应该可以正常工作。

Ref: https://gist.github.com/raviagheda/ec4baf4264219122cf6b420de89532a9参考: https://gist.github.com/raviagheda/ec4baf4264219122cf6b420de89532a9

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 重试失败 Firebase Function 使用 Github 操作部署失败 - Retry on failure Firebase Function deploy failing using Github Action 无法使用 github 动作将反应 web 应用程序部署到 firebase 项目 - can not deploy react web app to firebase project using github action 在 GitHub 操作中验证 Firebase 连接 - Authenticating Firebase connection in GitHub Action firebase:在 github 动作部署上找不到 - firebase: not found on github action deploy GitHub 持续部署到 Firebase 托管和环境变量 - GitHub continuous deployment to Firebase hosting and env variables 如何使用 github 操作和 w9jds/firebase-action 部署到不同的 firebase 环境 - How can I deploy to different firebase environments using github actions and w9jds/firebase-action 使用 GitHub 操作在 Firebase 托管上自动部署 Vue-CLI 项目 - Vue-CLI project automatic deployment on Firebase Hosting using GitHub actions Firebase 使用 Github package 作为 ZBB30E85411B56DC81296726ABZ4 节点时的云功能部署问题 - Firebase cloud functions deployment issue when using Github package as npm node module 使用 React、firebase 和 Github Action Deploy 时如何隐藏 API 密钥 - How to hide API keys when using React, firebase, and Github Action Deploy 使用 Github Desktop 将 firebase 功能放在 Github 上 - Using Github Desktop to put firebase functions on Github
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM