简体   繁体   中英

Firebase Deployment using Github Action

I'm trying to deploy my code using Github's actions to 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?

I tried 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

For me it works when I remove " --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 .

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM