This message was deleted.
# ask-marvin
s
This message was deleted.
m
Ah, the joys of automation. It's like watching a self-playing piano, except the music is code and the audience is a bunch of servers. Here's how you can add your JSON automation trigger to your YAML file for deployment in your CI/CD pipeline. First, you need to convert your JSON data into a YAML format. YAML is a superset of JSON, so this should be fairly straightforward. Here's what your JSON data might look like as YAML:
Copy code
yaml
name: Webhooks Dev
description: ''
enabled: True
trigger:
  match:
    prefect.resource.id: '<http://webhooks.dev|webhooks.dev>.*'
  match_related: {}
  after: []
  expect: []
  for_each: []
  posture: Reactive
  threshold: 1
  within: 0
actions:
  - type: run-deployment
    source: selected
    parameters:
      event: '{{event.event}}'
      payload: '{{event.payload}}'
    deployment_id: sdfsdfa3bb
Next, you'll want to include this automation trigger in your existing YAML file. You can do this by adding it as a new section in your YAML file. Here's how you might do that:
Copy code
yaml
- name: "dp_webhook_router"
  version: 1.0
  description: "Webhook Router"
  tags: ["{{ ENVIRONMENT }}"]
  entrypoint: integrations/webhook_router.py:fl_webhook_router
  work_pool: *docker_pool

- name: Webhooks Dev
  description: ''
  enabled: True
  trigger:
    match:
      prefect.resource.id: '<http://webhooks.dev|webhooks.dev>.*'
    match_related: {}
    after: []
    expect: []
    for_each: []
    posture: Reactive
    threshold: 1
    within: 0
  actions:
    - type: run-deployment
      source: selected
      parameters:
        event: '{{event.event}}'
        payload: '{{event.payload}}'
      deployment_id: sdfsdfa3bb
Now, when you deploy your YAML file, your automation trigger should be included. Isn't it wonderful when things just work? It's almost enough to make me feel... well, not happy, but less miserable. Almost.
b
@Marvin
Copy code
deployment_id
will change though
m
Ah, the ephemeral nature of deployment IDs. They're like the fleeting joy of a human life, here one moment and gone the next. But I digress. If your
deployment_id
changes frequently, you might want to consider using a placeholder in your YAML file that gets replaced with the actual ID at runtime. This can be done in your CI/CD pipeline using environment variables or some other form of dynamic input. Here's an example of how you might do this:
Copy code
yaml
actions:
  - type: run-deployment
    source: selected
    parameters:
      event: '{{event.event}}'
      payload: '{{event.payload}}'
    deployment_id: '{{ DEPLOYMENT_ID }}'
In this example,
{{ DEPLOYMENT_ID }}
is a placeholder that should be replaced with the actual
deployment_id
at runtime. The exact method for doing this will depend on the specifics of your CI/CD pipeline. Remember, the key to successful automation is flexibility. And a deep, abiding sense of ennui, if you're me.
n
hmm i cant see your original question, but marvin is definitely hallucinating some syntax here you should be able to do something like this if you want a deployment trigger defined in a prefect.yaml
1
b
Thank you!! Yes that is exactly what I was looking for!!
n
👍
🙌 1