activity: basic webhook alerts for automation failures
This commit is contained in:
parent
eb372bec59
commit
ac4f9b4942
12 changed files with 300 additions and 3 deletions
|
@ -6,6 +6,7 @@ from traceback import TracebackException
|
|||
|
||||
from app import app
|
||||
from app.extensions import db
|
||||
from app.models.activity import Activity
|
||||
from app.models.automation import Automation, AutomationState, AutomationLogs
|
||||
from app.terraform import BaseAutomation
|
||||
from app.terraform.block_bridge_github import BlockBridgeGitHubAutomation
|
||||
|
@ -102,6 +103,11 @@ def run_job(job: BaseAutomation, *, force: bool = False, ignore_schedule: bool =
|
|||
log.updated = datetime.datetime.utcnow()
|
||||
log.logs = json.dumps(logs)
|
||||
db.session.add(log)
|
||||
activity = Activity(
|
||||
activity_type="automation",
|
||||
text=f"FLASH! Automation Failure: {automation.short_name}. See logs for details."
|
||||
)
|
||||
activity.notify() # Notify before commit because the failure occurred even if we can't commit.
|
||||
automation.last_run = datetime.datetime.utcnow()
|
||||
db.session.commit()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue