6

I have a node-based rest api app running off of a single firebase function and I'm trying to setup a CD pipeline to deploy a staging function and another a production function.

The only way I've found to get this working was to have a 'production.ts' and 'staging.ts' and in each pipeline to rename the relevant one to index.ts.

This works and is successful but because it doesn't find the other function in there, it will not publish the new function, instead, it will revert everything?

This is the console output of my last run:

  functions: creating Node.js 10 function StagingAPI (europe-west2)...

Error: The following functions are found in your project but do not exist in your local source code:

    ProductionAPI (europe-west2)

Aborting because deletion cannot proceed in non-interactive mode. To fix, manually delete the functions by running:

    firebase functions:delete ProductionAPI --region europe-west2

How could I achieve this differently without having another completely separate firebase project?

I can see there's some discussions on github about it and even a pull request that attempts to fix this by providing a flag: --ignore-existing-functions

But it doesn't look like its going to be merged.

This must be a common issue.

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
SebastianG
  • 8,563
  • 8
  • 47
  • 111

1 Answers1

2

If you want to deploy a single function and ignore existing functions that are not part of your deploy set, simply use --only with this syntax:

firebase deploy --only functions:name-of-function

But it's much better overall to have different projects for different environments.

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
  • Thanks this works -- I'd create different projects if I'd be using any other firebase products, but I only need 2 functions, no firestore/auth/hosting/bucket. – SebastianG Jun 10 '20 at 14:09