Skip to content

Every hour

Open GitHub issues from failed backup emails

When a backup or scheduled job emails a failure report, a GitHub issue is opened with the details and you get an email with the link.

Runs
Every hour
Apps
GitHub, Gmail
AI
Optional
Access
gmail.readonly; issues:write

Send this to your assistant

Create a ClickRuntime automation: every hour, check Gmail for backup and cron report emails; if one shows a failure, open an issue in acme/infra with the error and email me the link.

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 small IT team runs nightly backups and a dozen scheduled jobs that report by email. The reports pile up in a folder nobody reads, so a backup that started failing three weeks ago is only discovered when someone needs to restore it.

Turning failure reports into GitHub issues puts them in the same place as the rest of the team's work. Each failure gets an owner and a status, and a backup problem is fixed the day it starts.

What you get out of it

  • Failures are not buried

    Success reports stay in the folder; failures become issues. The signal is separated from the noise.

  • Every failure has an owner

    An issue can be assigned and tracked to closed. Nobody has to remember that a job broke.

  • The error details are kept

    The issue includes the relevant lines from the report. Whoever investigates does not have to dig out the original email.

  • One issue per email

    Each report is handled once, so repeated checks never open duplicates of the same failure.

How it works

What happens, step by step

  1. Every hour, ClickRuntime looks in your Gmail for new reports from your backups and scheduled jobs.

  2. It checks each report for signs of failure, using keywords and, if you turn it on, AI.

  3. For each failure, it opens a GitHub issue with the job name, time and error lines.

  4. You get an email with a link to the new issue.

  5. Each report is handled once, so no duplicates are opened.

Before it runs live

  • Connect GitHub
  • Connect Google through your own Google app (a one-time, 10-minute setup), so it works with your own Gmail

What you get

RunsEvery hour
Open GitHub issues from failed backup emailstoday, 9:00Succeeded
Email · 1 job failures filedJob failed: Nightly backup report db-01. github.com/acme/infra/issues/212

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
  • Change what the AI looks for, or how it writes the result
  • Add another app, for example also send it to Slack
  • Combine it with other GitHub and Gmail 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.
log_failures_from_backups_jobs_as_github_issues.pyexample
import re
from google.oauth2.credentials import Credentials
from googleapiclient.discovery import build
from clickruntime import on_trigger, credentials, http, notify, state, ai, report_fetched

def gh(method, path, **kw):
    resp = http.request(method, f"https://api.github.com{path}", headers={
        "Authorization": f"Bearer {credentials.connection('github', 'work')}", "Accept": "application/vnd.github+json"}, **kw)
    return resp.raise_for_status() or (resp.json() if resp.content else None)

REPO, QUERY = "acme/infra", "subject:(backup OR cron) newer_than:1d"
FAIL = re.compile(r"error|failed|failure|exit code [1-9]", re.I)

@on_trigger
def run(event):
    gmail = build("gmail", "v1", credentials=Credentials(credentials.connection("google", "work")), cache_discovery=False).users()
    seen = set(state.get("seen") or [])
    new = [m["id"] for m in gmail.messages().list(userId="me", q=QUERY).execute().get("messages", []) if m["id"] not in seen]
    report_fetched(len(new))
    if not new:
        return {"issues": 0}
    opened = []
    for mid in new:
        msg = gmail.messages().get(userId="me", id=mid, format="metadata", metadataHeaders=["Subject"]).execute()
        subject, text = msg["payload"]["headers"][0]["value"], msg["snippet"]
        failed = bool(FAIL.search(text))
        try:
            failed = ai.generate(text, system="Does this job report describe a failure? Answer yes or no.", max_output_tokens=5).text.lower().startswith("yes")
        except (ai.AINotIncluded, ai.AILimitReached):
            pass
        if failed:
            issue = gh("POST", f"/repos/{REPO}/issues", json={"title": f"Job failed: {subject}"[:200], "labels": ["ops"], "body": f"From the job report email:\n\n> {text}"})
            opened.append(issue["html_url"])
        seen.add(mid)
    if opened:
        notify.email_me(f"{len(opened)} job failures filed", "\n".join(opened))
    state.set("seen", sorted(seen)[-500:])
    return {"issues": len(opened)}

FAQ

Common questions

How does it tell a failure from a success?
By words in the report such as error, failed or exit code, which you can adjust. With AI turned on, it reads less obvious reports and decides whether they describe a problem.
Which emails does it look at?
Only those matching a Gmail search you set, such as messages from your backup tool or with Backup report in the subject.
Will a job that fails every night open an issue every night?
Yes, by default, so you can see how long it has been failing. You can ask it to comment on the open issue instead of opening a new one.
What permissions does it need?
gmail.readonly; issues:write. Nothing else in your accounts is used.
Does it need AI?
No, but you can ask for an AI step (for example a summary). It then uses ClickRuntime's built-in 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 “Open GitHub issues from failed backup emails” from your assistant

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