Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

CI alerts: send the Alertmanager intake password (CUA-2258) (#5911)

cua-agents[bot]1b447a23b1d2
diff --git a/.github/scripts/workflow_alerts.py b/.github/scripts/workflow_alerts.py
index 9adf78ea3c..5c63ae2c34 100644
--- a/.github/scripts/workflow_alerts.py
+++ b/.github/scripts/workflow_alerts.py
@@ -25,6 +25,7 @@ conclusions change nothing. Standard library only.
from __future__ import annotations
import argparse
+import base64
import datetime as dt
import json
import os
@@ -118,13 +119,14 @@ def build_alert(run: dict, name: str, repo: str, environment: str, now: dt.datet
return {"labels": labels, "annotations": annotations, "startsAt": starts, "endsAt": ends}
-def http_json(url: str, token: str = "", data: object = None, attempts: int = 3):
+def http_json(url: str, token: str = "", data: object = None, attempts: int = 3, extra_headers: dict | None = None):
body = None if data is None else json.dumps(data).encode()
headers = {"Accept": "application/vnd.github+json", "User-Agent": "workflow-alerts"}
if body is not None:
headers["Content-Type"] = "application/json"
if token:
headers["Authorization"] = "Bearer " + token
+ headers.update(extra_headers or {})
for attempt in range(1, attempts + 1):
request = urllib.request.Request(url, data=body, headers=headers, method="POST" if body is not None else "GET")
try:
@@ -185,7 +187,10 @@ def latest_runs(repo: str, watch: dict[str, str], token: str, default_branch: st
def post(alerts: list[dict], url: str) -> None:
if alerts:
- http_json(url, data=alerts)
+ # The alert intake wants basic auth (user "alerts"). No token = no header, so local runs still work.
+ secret = os.environ.get("ALERTMANAGER_INTAKE_TOKEN", "")
+ auth = {"Authorization": "Basic " + base64.b64encode(("alerts:" + secret).encode()).decode()} if secret else None
+ http_json(url, data=alerts, extra_headers=auth)
def main(argv: list[str] | None = None) -> int:
diff --git a/.github/workflows/release-unreleased-digest.yml b/.github/workflows/release-unreleased-digest.yml
index ae6120fca6..756fb9cc3a 100644
--- a/.github/workflows/release-unreleased-digest.yml
+++ b/.github/workflows/release-unreleased-digest.yml
@@ -20,6 +20,8 @@ jobs:
fetch-tags: true
- name: Check for unreleased changes per package
+ env:
+ ALERTMANAGER_INTAKE_TOKEN: ${{ secrets.ALERTMANAGER_INTAKE_TOKEN }}
run: |
# Service → tag prefix → directory
declare -A SERVICE_TAG_DIR
@@ -71,7 +73,8 @@ jobs:
DESCRIPTION=$(echo -e "$UNRELEASED" | sed 's/$/; /' | tr -d '\n' | sed 's/; $//')
# Send alert to AlertManager → Slack
- curl -s -X POST https://am.cua.ai/api/v2/alerts \
+ # The alert intake needs a password (repository secret ALERTMANAGER_INTAKE_TOKEN).
+ curl -s -u "alerts:${ALERTMANAGER_INTAKE_TOKEN}" -X POST https://am.cua.ai/api/v2/alerts \
-H "Content-Type: application/json" \
-d "[
{
diff --git a/.github/workflows/workflow-failure-alerts.yml b/.github/workflows/workflow-failure-alerts.yml
index e9d18516ef..c4c52ec05d 100644
--- a/.github/workflows/workflow-failure-alerts.yml
+++ b/.github/workflows/workflow-failure-alerts.yml
@@ -68,6 +68,7 @@ jobs:
Release: installer scripts feed=release
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
GH_TOKEN: ${{ github.token }}
+ ALERTMANAGER_INTAKE_TOKEN: ${{ secrets.ALERTMANAGER_INTAKE_TOKEN }}
steps:
- uses: actions/checkout@v4
with: