gpt4 book ai didi

firebase - Firebase 托管是否提供可以收听的部署事件?

转载 作者:行者123 更新时间:2023-12-04 02:05:29 24 4
gpt4 key购买 nike

我希望能够监听 Firebase Hosting 在成功部署后引发的事件。今天在 Google Firebase 平台上可用吗?计划创建一个部署事件处理程序来发送一个 Slack webhook 请求,其中包含有关成功部署的上下文信息。

最佳答案

firebase-tools 最近添加了挂接到 predeploypostdeploy 进程的功能:

To set up deployment hooks, add bash scripts to the firebase.json configuration file for the project. Brief scripts can be defined directly in the file, or you can reference files in your project directory. For example, here is the firebase.json expression for a postdeploy script that sends a Slack message on successful completion of a deployment to Firebase hosting:

{
"hosting": {
"postdeploy": "./messageSlack.sh 'Just deployed to Firebase Hosting'"
}
}

The messageSlack.sh script residing in the project directory would look like:

curl -X POST -H 'Content-type: application/json' --data '{"text":"$1"}' https://<Slack_Webhook_URL>

For any of the assets you can deploy—hosting, functions, database, storage, and firestore— you can add predeploy and postdeploy hooks in firebase.json, and your scripts will run with the corresponding deployment command. Both predeploy and postdeploy hooks print the standard output and error streams of the scripts to the terminal. For failure cases, note that:

Failure to complete a predeploy hook as expected cancels the deployment. Where deployment fails for any reason, postdeploy hooks are not triggered.

Source - Firebase CLI Reference

关于firebase - Firebase 托管是否提供可以收听的部署事件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43765963/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com