![](/img/trans.png)
[英]Firebase Hosting Flutter Web App not clearing Cache of first deploy
[英]Automatically Deploy Flutter Web Project to Firebase Hosting with Codemagic CI/CD
如何使用 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
有誰知道我如何編寫實現預期結果的自定義腳本?
根據我的電子郵件
默認情況下,Firebase CLI 安裝在 Codemagic 機器上,因此正如 Mikhail 所說,您必須將FIREBASE_TOKEN
添加到您的環境變量中,請先使用 Codemagic UI 對其進行加密。
您可以通過在本地控制台中運行login:ci
來獲取令牌。 然后在構建步驟之后,您只需在項目的根目錄中運行firebase deploy --token "$FIREBASE_TOKEN"
(在 UI 的構建后腳本中,或將其添加到您的 .yaml 中),Codemagic 所在的位置在默認情況下。
在從 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'
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.