I'd like to be able to listen to Firebase Hosting for events that it would raise after a successful deployment. Is this available today in the Google Firebase platform? Planning to create a deployment event handler to send a Slack webhook request with context information about the successful deployment.
firebase-tools recently added the ability to hook into the predeploy and postdeploy processes:
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.shscript 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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With