<@ULVA73B9P> When I deploy a new flow from my pref...
# ask-marvin
t
@Marvin When I deploy a new flow from my prefect.yaml file, can I also add that flow straight into an existing automation at the same time?
m
It seems that you can create and configure automations programmatically using a YAML file and by interacting with the Prefect API. However, there isn't a direct mention in the excerpts I've found about adding a newly deployed flow to an existing automation simultaneously during the deployment process from a
prefect.yaml
file. To achieve this, you generally would follow these steps separately: 1. Define or update your flow's deployment in the
prefect.yaml
file. 2. Deploy the flow using the Prefect CLI or the Prefect API. 3. Either programmatically create a new automation or update an existing automation using the Prefect API to include the new deployment. If you already have an existing automation, you would modify it to incorporate your new flow deployment. You would need the deployment ID of your newly deployed flow which you could then specify in the automation's action section. Here's a template example for an automation's YAML that features a
run-deployment
action:
Copy code
yaml
name: My Custom Automation
description: An example automation to redeploy a flow based on an event
trigger:
  # Your trigger conditions here
actions:
- type: "run-deployment"
  source: "selected"
  deployment_id: "YOUR-NEW-DEPLOYMENT-ID" # update this with the actual deployment ID
  parameters: {} # any parameters you want to set for the flow run
For more detailed instructions and examples, check the full guide on Automations in the Prefect documentation. Keep in mind that tying these two operations together (deployment and automation update) into a single step would likely require a custom script using the Prefect API.