Run "deployment apply" for multiple yaml files at once

Hi (-:

We have several deployments running in production (scheduled with a CRON expression).
All of those deployments share a common piece of code coming from a .py file.
if I update this .py file, I now need to run the “apply” command for each of the .yaml files. For example:

prefect deployment apply jobs/selfServiceDaily.yaml

Are there any shortcuts to apply many yaml files at once?

1 Like

Perhaps a subprocess?

import subprocess

def bash(command: str):
    subprocess.run(command, shell=True)

for i in files:
    bash(f"prefect deployment apply jobs/{i}")
1 Like

Got it! (-:
Thinking out load, aren’t many others are at the same situation?
I think it would be very helpful to have an option in the CLI to run:

prefect deployment apply <some_folder>

And the CLI will automatically apply all the yaml found in the folder (could be recursive).

1 Like

YAML is not required, though, you can build and apply from both CLI and from Python code.

Check out how I did that in CI:

1 Like

Amazing :pray:
Will take a look…

1 Like

Hi Yaron, I am in a similar situation. What solution did you implement to deploy and setup a CI/CD with the deployment yamls?

Hi Sunjay,
We didn’t implement Prefect into our CI/CD pipeline yet.