Deploy all functions at once
Feature request
Is your feature request related to a problem? Please describe.
During for example a CI/CD workflow it seems difficult to deploy changes when new functions have been created/updated/deleted
Describe the solution you'd like
based on a configuration file inside the functions directory ( with all options required per function ) it would be nice to deploy all of them at once. Of course if nothing changed or function already exist the operation won't be the same on your side.
The command line could look something like that.
`supabase functions deploy --all
So basically you could create a function
supabase functions new myFunction
which would then create a default config file if none exist like functions.config.ts which would be the default config file, if you want to pass another config file you could add an option --config where you could add the path to the desired config file or something like `supabase functions --set-config my/path.ts to avoid writing back the parameter everytime.
functions.config.ts
{
"functions": {
"myFunction": {
"options": {
"no-verify-jwt":false,
"--env-file":""
}
}
}
}
Describe alternatives you've considered
creating an obscure bash script to detect updates in folder and loop through result to deploy them one by one
Additional context
On my side this is mainly to automate process, deploying functions outside of the development pipeline can lead to more errors. I think we can merge this enhancement with this issue #431
Sounds good - I think we can make supabase functions deploy deploy all (modified) functions if called without a function name.
@soedirgo how deploy all will handle the option like jwt ? and you closed the issue but i don't see it in the all option in the doc, does it done ?
@riderx when creating new function you could pass those parameters which would be written in a config file and be updated on each single deploy of course you could also edit the config file. Just an idea.
Thanks, do we have a way to create this file for already existing functions?
We probably want to do https://github.com/supabase/cli/issues/280 first so that supabase functions deploy determine whether or not to verify JWT for each function.
@soedirgo as mentionned above do you think you could also add the env file path too?
Can you clarify what you mean by the env file? What does it get used for? I was thinking of adding the config in the existing supabase/config.toml, as per #280.
@soedirgo I cannot really advice where to put it but for env I'm talking about --env-file flag you can pass when you serve the function, it could be nice to set the path in a config file this would lighten commands like supabase secrets set --env-file .env to supabase secrets set ( again just an idea) also and this another subject I wasn't able to serve multiple functions at once I guess we could rename this issue to "implement bulk operations commands".
Gotcha - tracking that on https://github.com/supabase/cli/issues/459. There's no need to add a env-file config since supabase functions serve already has it as a flag.
Any news on that ? at leas i wish the deploy method could be run in paralell for now it's breaking if i do that, so updating my function take 1 min to do it one by one it's a big cost in CI/CD
i did tried again to deploy all function in paralell and still the issue : https://github.com/Cap-go/capgo/actions/runs/4613986040/jobs/8156531019
We basically decided to have one main edge function that acts as a router due to the limitation of not being able to deploy all. It limits the ability to scale. Hopefully, this can be added soo!
We have added the ability to supabase functions deploy which defaults to deploying all functions in supabase/functions directory in sequence.
Currently it does not deploy all in parallel due a limitation of our api. If it becomes a performance bottleneck for your use case, please feel free to file a new issue.
I am the only one receiving error when deploying all?
$ supabase functions deploy --debug
Supabase CLI 1.88.0
Version 1.30.3 is already installed
Invalid Function name. Must start with at least one letter, and only include alphanumeric characters, underscores, and hyphens. (^[A-Za-z][A-Za-z0-9_-]*$)
Am I missing something?
This error indicates a malformed function name. Could you do a ls -la supabase/functions to help confirm?
Right. There are other directories in the folder, all prefixed by underscore to differentiate from edge-functions (_domain, _app). That's shared code.
I couldn't move those deps to a parent directory because (on local-dev) the supabase-cli copies over (to the Deno docker container) only the files under the supabase/functions folder.
Another reason... iirc, was also to solve issues resulting in different parsing/linting among VSCode, Deno-VSCodeExtension and the Deno-in-the-container. So I opted for the whole application source to stay under a single directory.
@sweatybridge any idea how should I handle my case? Is there any way to move the shared code somewhere else up in the directory hierarchy?
Also, from how I see it, the directories I created are outside of the valid pattern for edge-functions name (the starting _ indeed), hence should be acceptable to have them.
Although I understand that you might not know how to distinguish legit non-function folders from wrongly named function folders.
Maybe, to instruct the CLI how to do that, we need to add one more option to the config.toml, as was already done for verify-jwt and import-map?
I can go on deploying manually each function for now, but it would be nice to get the ability to deploy-all from CI/CD even tho there's shared code in the same namespace.
the directories I created are outside of the valid pattern for edge-functions name (the starting _ indeed), hence should be acceptable to have them.
I think this is a reasonable expectation so I've created a PR to fix it.
Meanwhile, you can deploy multiple functions passing in all their names. For eg.
supabase functions deploy func_1 func_2
@sweatybridge do we have documentation for deploy all with option like no jwt ?
Oh i found the doc here: https://supabase.com/docs/guides/functions/cicd-workflow thanks a lot
Thank you a bunch @sweatybridge !