How to launch a script before each deployment?


When I deploy a Repl, I like to purge all dev logs and delete some cache files to have a clean version on production.
I can do that with a .sh or manually.

Is there a way to do it automatically before each deployment ?
There is a optional build script but I don’t see how i can launch my own script with it

If it doesn’t exist I think it can be a nice feature with deployments, as we are now forced to use them :slight_smile:

Setting some stuff in the hidden .replit file might be what you are looking for:

run = ["bash", ""]


Thanks for your answer,

I have tried to put :

build = ["sh", "-c", "python3"]
run = ["sh", "-c", "python3"]
deploymentTarget = "cloudrun"

But it does’t launch my script, how can i do ?
I have tried with a .sh but it doesn’t work

Test if the command is actually being run to see if the problem is the command or configuration:

build = ["echo", "command ran successfully"]
run = ["echo", "command ran successfully"]
deploymentTarget = "cloudrun"

If the command does not run, then there is a problem with configuration (which could possibly be a replit bug).
Else if it does run, then your original command needs to be changed. Here, someone else will have to help you since deployments and sh is out of the scope of my knowledge. (is it possible to remove sh -c?)

No sorry it did not work
The build part never appeared and once deployed the run command made an infinite loop of “echo command ran succesfully”

I have created a function for cleaning in my and launched only if i’m deployed but i would be happy to have a feature to launch a script before deploying :slight_smile:

1 Like