【问题标题】:How can I deploy to different firebase environments using github actions and w9jds/firebase-action如何使用 github 操作和 w9jds/firebase-action 部署到不同的 firebase 环境
【发布时间】:2020-10-05 09:22:46
【问题描述】:

我正在尝试使用 Github Actions 为我的 Angular 项目设置 CI 到 firebase,但我同时拥有一个暂存环境和生产环境,我想根据我推送到的分支部署到它们中的每一个。

我知道我可以为 masterdev 分支创建两个不同的工作流脚本,但我不知道如何使用 w9jds/firebase-action 部署到不同的 firebase 环境。

当我使用脚本时:

on:
  push:
    branches:
      - dev

jobs:
  build:
    name: Build
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Repo
        uses: actions/checkout@master
      - name: Install Dependencies
        run: npm install
      - name: Build
        run: npm run build-prod
      - name: Archive Production Artifact
        uses: actions/upload-artifact@master
        with:
          name: dist
          path: dist
  deploy:
    name: Deploy
    needs: build
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Repo
        uses: actions/checkout@master
      - name: Download Artifact
        uses: actions/download-artifact@master
        with:
          name: dist
          path: dist
      - name: Deploy to Firebase
        uses: w9jds/firebase-action@master
        with:
          args: deploy --only hosting:staging
        env:
          FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}

我收到以下错误:

Error: No project active, but project aliases are available.

Run firebase use <alias> with one of these options:

  production (#####)
  staging (#####)

我做错了什么?

【问题讨论】:

    标签: firebase github firebase-hosting github-actions firebase-cli


    【解决方案1】:

    我认为你需要:

    with:
      args: deploy --only hosting --project staging
    

    hosting:* 部署目标适用于同一项目中的多个站点,要指定一个项目,您应该使用 --project-P

    【讨论】:

    • 这正是我想要的!非常感谢!
    猜你喜欢
    • 2020-10-11
    • 2020-04-18
    • 2020-09-25
    • 2021-03-31
    • 2021-01-19
    • 2021-03-15
    • 2021-09-16
    • 2020-10-20
    • 2017-08-17
    相关资源
    最近更新 更多