firebasegoogle-cloud-functionsfirebase-cli

Don't delete firebase cloud funtions


I'm configuring CD process on gitlab to google cloud functions (firebase). Also i have 3 envs (development, staging and production) and i want to deploy each function with matching postfix (_development, _staging).

When i deploy functions to development, for instance, from my local machine with command

firebase deploy --only functions

it always asks me

Would you like to proceed with deletion? Selecting no will continue the rest of the deployments.

And i choose "No", because i don't want to delete existing functions with other postfixes. But on gitlab there is no possibility to enter "No" and it decides to delete all that functions as default.

Is there some solution to not delete existing functions in cloud? Probably some flag in deploy command?


Solution

  • The way you are managing environments is not recommended by the Firebase team. You should be using different projects to isolate the different environments as described in the documentation.

    But if you absolutely can't make any changes to what you're doing, what you will have to do is call out the names of each function to deploy, as described in the documentation:

    By default, the Firebase CLI deploys all of the functions inside index.js at the same time. If your project contains more than 5 functions, we recommend that you use the --only flag with specific function names to deploy only the functions that you've edited. Deploying specific functions this way speeds up the deployment process and helps you avoid running into deployment quotas. For example:

    $ firebase deploy --only functions:addMessage,functions:makeUppercase
    

    Or, you can use function groups.