Skip to content

Every 5 minutes

Get emailed when a production deploy fails

A broken production build reaches you with Netlify's error message, while branch previews stay quiet.

Runs
Every 5 minutes
Apps
Netlify
AI
Not needed
Access
read (the PAT has full access)

Send this to your assistant

Create a ClickRuntime automation: every 5 minutes, check my Netlify site marketing-site for failed production deploys and email me the error message for any new failure.

Paste it into your assistant. It tells you what it will send or change before it runs live.

First time? Adding ClickRuntime to your assistant takes about two minutes.

Why use it

Why teams use this automation

A broken build on a feature branch is a normal part of development, and Netlify emails the author about it. A failed production deploy is different: the site is still serving the old version, so everything looks fine, while a hotfix or pricing change sits undeployed. If nobody reads the build email, the team may believe a fix is live for hours, and customers keep hitting the bug.

Every five minutes ClickRuntime lists the site's deploys and keeps those in the error state whose context is production, ignoring branch previews and deploy previews. It sends an email with the commit, branch and error summary, then remembers the deploy IDs so each failure produces a single message.

Teams that deploy automatically on merge, where nobody watches the build, benefit most. It also helps agencies that watch many client sites.

What you get out of it

  • Hotfixes that did not ship are noticed

    If the fix you merged at 11:00 failed to deploy, you hear by 11:10. You do not tell a customer that it is fixed while the old code is still live.

  • Only production failures interrupt people

    Branch preview errors are everyday work and filtered out. The email means something important failed, so people act on it instead of filtering it away. Preview errors are normal work, so only real incidents interrupt anyone.

  • Context is included for a quick diagnosis

    The message names the commit and the error. Often the cause, such as a missing environment variable, is visible without opening the build log. Often the cause, such as a missing variable, is visible without opening the full build log.

  • No silent drift between repository and site

    A failed production build means main and the live site no longer match. Catching it quickly keeps that gap small and avoids confusion about what is deployed. Catching a failed build quickly keeps that gap small and avoids confusion.

  • Each failure is reported once

    Stored deploy IDs prevent repeat emails for the same failure. When the next deploy fails differently, you get a new message, so the inbox stays honest. When the next deploy fails differently you still get a fresh message.

How it works

What happens, step by step

  1. Every five minutes ClickRuntime checks your Netlify site's recent deploys.

  2. It keeps only failed production deploys, so branch previews stay quiet, and skips any it has already reported.

  3. You get an email with the branch and Netlify's error message.

Before it runs live

  • Connect Netlify

What you get

RunsEvery 5 minutes
Get emailed when a production deploy failstoday, 9:00Succeeded
Email · Deploy failedNetlify production deploy failed (main) Build script returned non-zero exit code: 2

Build your own

Need it to work differently?

This template is a starting point. Copy the prompt and change it, or describe a different automation from scratch, with your own conditions, more apps or an AI step. Your assistant writes it, tests it and runs it on ClickRuntime.
  • Your own rules

    Conditions, thresholds, filters and exceptions, written the way you'd explain them to a colleague.

  • Any number of apps

    One automation can read from one app and update several others. Over 248 apps are ready, and anything with an API works too.

  • AI where it helps

    Summaries, classification, extraction and drafts use ClickRuntime's built-in AI, with no extra key.

  • On a schedule or on each event

    Runs as often as every 5 minutes, or the moment an app sends an event, and keeps track of what it already handled.

Changes you can ask for

  • Act only on the items that match your own rules, and skip the rest
  • Add an AI step, for example to summarize, sort or draft a reply
  • Add another app, for example also send it to Slack
  • Combine it with other Netlify steps into one automation

Under the hood

The code that runs this automation

This is the Python script that runs each time the automation starts. Your AI assistant writes it for you when you send the prompt, and you allow each step in your assistant. To change how the automation works, describe the change to your assistant and it updates the script for you. For every function it can use, see the script reference.
get_alerted_on_failed_production_deploys.pyexample
from clickruntime import on_trigger, credentials, http, notify, state, report_fetched

SITE_ID = "your-netlify-site-id"

def netlify(path, **params):
    resp = http.get(f"https://api.netlify.com/api/v1/sites/{SITE_ID}/{path}", params=params,
                    headers={"Authorization": f"Bearer {credentials.secret('NETLIFY_TOKEN')}"})
    resp.raise_for_status()
    return resp.json()

@on_trigger
def run(event):
    deploys = netlify("deploys", per_page=20)
    seen = set(state.get("seen") or [])
    new = [d for d in deploys if d["state"] == "error" and d["context"] == "production" and d["id"] not in seen]
    report_fetched(len(new))
    if not new:
        return {"failed": 0}
    for d in new:
        notify.email_me(f"Netlify production deploy failed ({d.get('branch')})", d.get("error_message") or "No error message")
    state.set("seen", list(seen | {d["id"] for d in new})[-200:])
    return {"failed": len(new)}

FAQ

Common questions

How does it tell production from previews?
Netlify tags each deploy with a context such as production, deploy-preview or branch-deploy. The check keeps only production deploys with the error state, so previews never create a message. Preview contexts never create a message.
Does a canceled build count as a failure?
No. Canceled builds have their own state and are skipped, since they are usually intentional. Only builds that ended in error are reported, along with the failure summary Netlify records. That keeps routine cancellations out of your inbox.
Can I cover several Netlify sites?
Yes. The check can loop over a list of site IDs or all sites in your team, and each message names the site. Include the sites you care about and use a token with access to them.
What permissions does it need?
read (the PAT has full access). Nothing else in your accounts is used.
Does it need AI?
No. It runs without AI, so it doesn't use your plan's AI allowance.
How many runs does it use?
One run each time it checks. Checks that find nothing new and stop right away aren't counted.
Can I change how it works?
Yes. Describe the change to your AI assistant, for example a different schedule, channel or filter. It updates the automation, tests it and tells you what changed.

Set up “Get emailed when a production deploy fails” from your assistant

Copy the prompt above, or connect your assistant first. Free plan, no credit card.