如何使用CodeMagic.io将Flutter Web应用程序构建自动部署到Firebase托管?
当前似乎唯一受支持的选项是Codemagic静态页面和Amazon S3存储桶。除非使用自定义构建脚本。
我已经对自定义生成脚本选项进行了一些研究,但是在线上没有太多有关自动部署到Firebase托管的信息。尽管我怀疑您可能可以修改Codemagic分发文档中提供的示例(“使用Firebase CLI发布应用” [https://docs.codemagic.io/publishing-yaml/distribution/])以实现此目的。请参见下面的代码摘录。
- name: Publish the app to Firebase App Distribution
script: |
apkPath=$(find build -name "*.apk" | head -1)
if [[ -z ${apkPath} ]]
then
echo "No apks were found, skip publishing to Firebase App Distribution"
else
echo "Publishing $apkPath to Firebase App Distribution"
firebase appdistribution:distribute --app <your_android_application_firebase_id> --groups <your_android_testers_group> $apkPath
fi
有人知道我如何编写实现所需结果的自定义脚本吗?
答案 0 :(得分:2)
根据我的电子邮件
Firebase CLI默认情况下安装在Codemagic机器上,因此,就像Mikhail所说的那样,您将必须向环境变量中添加FIREBASE_TOKEN
,请首先使用Codemagic UI对其进行加密。
您可以通过在本地控制台中运行login:ci
获得令牌。然后,在构建步骤之后,您只需在项目的根目录中运行firebase deploy --token "$FIREBASE_TOKEN"
(在UI的后构建脚本中,或将其添加到您的.yaml中),默认情况下是Codemagic。
答案 1 :(得分:1)
从CI / CD服务进行部署之前,请确保您已完成以下步骤:
firebase init
创建了Firebase项目firebase.json
添加到存储库下一步是配置CI / CD工作流程
FIREBASE_TOKEN
添加到环境变量中(如果使用Codemagic UI配置,请检查https://docs.codemagic.io/flutter/env-variables/)#!/bin/sh
cd $FCI_BUILD_DIR
firebase deploy -m 'my comment'