使用 Github Action 失败时重试 Firebase 函数部署失败

时间:2021-02-13 03:02:41

标签: firebase google-cloud-functions firebase-cli firebase-tools

我有一个 firebase 函数,它在 firestore doc OnCreate 上触发,failurePolicy 设置为 true,如下所示:

const webhookHandler = functions
  .runWith({
    failurePolicy: true,
    memory: '512MB',
    timeoutSeconds: 60,
  }).firestore.document(`${COLLECTIONS.eventsQueue}/{event_queue_id}`)
  .onCreate(async (snap, context) => {

   //some code here...
})

在本地,使用 Firebase CLI 我可以成功部署,但需要我承认此功能会在失败时重试,您还想部署吗? 是/否

一旦选择,该函数将成功部署。

我正在使用 Github Actions 在 PR 合并时自动部署 firebase 功能。一旦我添加了上述功能,github 操作部署就会失败。

我的假设是 github action deploy 失败,因为提示。

我的 github 部署 github 动作脚本确实有 --non-interactive,也尝试过 --force,但一直失败。

似乎 --force 并没有在本地部署或在 github 部署中强制执行此功能。任何解决此问题的建议。

2 个答案:

答案 0 :(得分:1)

您可以使用大多数 linux 发行版中包含的 yes 命令。

yes | firebase deploy ...

答案 1 :(得分:0)

归功于@nVitus 帮助解决了这个问题。

解决它的确切脚本:

yes | firebase deploy --only functions --force