Skip to content

Recetas de CI/CD · Developers

Recetas listas para notificar a Dailybot desde cualquier pipeline. El mismo patrón que usan los workflows de release de Dailybot: un curl contra la API pública — sin runtime que instalar, sin CLI que mantener al día.

Todo vendor de CI soporta variables de entorno y secretos — eso es todo lo que necesitas para hablarle a Dailybot. Las recetas de abajo usan `curl` + `jq` contra la API REST pública, el mismo patrón que usan los propios workflows de release de Dailybot. ¿Prefieres un CLI? Salta a la sección de CLI.

¿Qué endpoint?

Dos endpoints cubren la gran mayoría de casos de CI/CD. Ambos aceptan un header X-API-KEY y devuelven JSON.

MethodPathWhen
POST/v1/send-message/Notifica a un canal, usuario o equipo en tu plataforma de chat conectada (Slack, MS Teams, Discord, Google Chat). Ideal para alertas de deploy iniciado / deploy en vivo / build fallido.
POST/v1/agent-reports/Envía un standup como identidad de agente. Ideal para resúmenes nocturnos por cron, reportes por deploy, y cualquier update recurrente de "qué pasó hoy".

Recetas API-first

Cada snippet es non-blocking: si Dailybot está inalcanzable un momento, el pipeline continúa. Los timeouts (--connect-timeout 10 --max-time 30) siguen el patrón de los workflows de este mismo sitio.

GitHub Actions — notificar un canal

# .github/workflows/notify-deploy.yml
name: Notify deploy
on:
  workflow_run:
    workflows: ["release"]
    types: [completed]

jobs:
  notify:
    runs-on: ubuntu-latest
    timeout-minutes: 3
    steps:
      - name: Install jq
        run: sudo apt-get update && sudo apt-get install -y jq

      - name: Post to Dailybot
        env:
          # UUID del canal en tu workspace de Dailybot.
          DAILYBOT_CHANNEL: ${{ vars.DAILYBOT_DEPLOY_CHANNEL }}
        run: |
          MESSAGE=$'✅ *Deploy en vivo*\n> commit: `'"${GITHUB_SHA:0:8}"'`\n> actor: '"$GITHUB_ACTOR"
          BODY=$(jq -n --arg msg "$MESSAGE" --arg ch "$DAILYBOT_CHANNEL" \
            '{message: $msg, target_channels: [$ch]}')
          curl --fail --show-error --connect-timeout 10 --max-time 30 \
            'https://api.dailybot.com/v1/send-message/' \
            -H "X-API-KEY: ${{ secrets.DAILYBOT_API_KEY }}" \
            -H 'Content-Type: application/json' \
            -d "$BODY" \
            || echo "Notificación a Dailybot falló; continúa."

GitHub Actions — enviar reporte de agente

# .github/workflows/nightly-report.yml
name: Nightly agent report
on:
  schedule:
    - cron: "0 23 * * *"

jobs:
  report:
    runs-on: ubuntu-latest
    timeout-minutes: 3
    steps:
      - name: Install jq
        run: sudo apt-get update && sudo apt-get install -y jq

      - name: Enviar reporte
        run: |
          BODY=$(jq -n \
            --arg summary "Batch nocturno completo en ${GITHUB_REF_NAME}." \
            --argjson milestone false \
            '{summary: $summary, milestone: $milestone}')
          curl --fail --show-error --connect-timeout 10 --max-time 30 \
            'https://api.dailybot.com/v1/agent-reports/' \
            -H "X-API-KEY: ${{ secrets.DAILYBOT_API_KEY }}" \
            -H 'Content-Type: application/json' \
            -d "$BODY" \
            || echo "Reporte de agente falló; continúa."

GitLab CI

# .gitlab-ci.yml (fragmento)
notify-dailybot:
  stage: notify
  image: alpine:3
  before_script:
    - apk add --no-cache curl jq
  variables:
    DAILYBOT_CHANNEL: "$DAILYBOT_DEPLOY_CHANNEL"  # UUID, guardada como variable masked
  script: |
    BODY=$(jq -n \
      --arg msg "Pipeline ${CI_PIPELINE_ID} en verde en ${CI_COMMIT_REF_NAME}." \
      --arg ch "$DAILYBOT_CHANNEL" \
      '{message: $msg, target_channels: [$ch]}')
    curl --fail --show-error --connect-timeout 10 --max-time 30 \
      'https://api.dailybot.com/v1/send-message/' \
      -H "X-API-KEY: $DAILYBOT_API_KEY" \
      -H 'Content-Type: application/json' \
      -d "$BODY" \
      || echo "Notificación a Dailybot falló; continúa."
  only:
    - main

CircleCI

# .circleci/config.yml (fragmento)
version: 2.1
jobs:
  notify-dailybot:
    docker:
      - image: cimg/base:current
    steps:
      - run:
          name: Post to Dailybot
          command: |
            BODY=$(jq -n \
              --arg msg "Job ${CIRCLE_JOB} en verde en ${CIRCLE_BRANCH}." \
              --arg ch "$DAILYBOT_DEPLOY_CHANNEL" \
              '{message: $msg, target_channels: [$ch]}')
            curl --fail --show-error --connect-timeout 10 --max-time 30 \
              'https://api.dailybot.com/v1/send-message/' \
              -H "X-API-KEY: $DAILYBOT_API_KEY" \
              -H 'Content-Type: application/json' \
              -d "$BODY" \
              || echo "Notificación a Dailybot falló; continúa."
workflows:
  build-and-notify:
    jobs:
      - notify-dailybot:
          context: dailybot-org  # guarda aquí DAILYBOT_API_KEY + DAILYBOT_DEPLOY_CHANNEL

Bash / cron

# /etc/cron.d/dailybot-nightly-report
# Cada día a las 23:00 UTC, envía un standup de resumen.
SHELL=/bin/bash
# Carga DAILYBOT_API_KEY desde tu secret store del host; nunca lo hardcodees aquí.
0 23 * * * app source /etc/dailybot.env && curl --fail --show-error --connect-timeout 10 --max-time 30 \
  'https://api.dailybot.com/v1/agent-reports/' \
  -H "X-API-KEY: $DAILYBOT_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"summary":"Batch nocturno completo.","milestone":false}' \
  >> /var/log/dailybot-report.log 2>&1

Kubernetes CronJob

# k8s/dailybot-nightly.yaml (fragmento)
apiVersion: batch/v1
kind: CronJob
metadata:
  name: dailybot-nightly-report
spec:
  schedule: "0 23 * * *"
  jobTemplate:
    spec:
      template:
        spec:
          restartPolicy: OnFailure
          containers:
            - name: dailybot
              image: curlimages/curl:8.10.1
              envFrom:
                - secretRef: { name: dailybot-secrets }   # expone DAILYBOT_API_KEY
              command: ["sh", "-c"]
              args:
                - |
                  curl --fail --show-error --connect-timeout 10 --max-time 30 \
                    'https://api.dailybot.com/v1/agent-reports/' \
                    -H "X-API-KEY: $DAILYBOT_API_KEY" \
                    -H 'Content-Type: application/json' \
                    -d '{"summary":"Mantenimiento nocturno corrió limpio.","milestone":false}'

¿Prefieres un CLI?

El CLI de Dailybot es un paquete de Python publicado en PyPI: pypi.org/project/dailybot-cli. Envuelve los mismos endpoints — `dailybot chat send …` llama a `/v1/send-message/`, `dailybot agent update …` llama a `/v1/agent-reports/`. Para CI/CD recomendamos las recetas con curl de arriba (sin runtime que instalar, una sola llamada HTTP, siempre en sync con la API). El CLI encaja mejor en desarrollo local y en procesos de agente de larga duración.

# Recomendado — one-liner universal (macOS, Linux, WSL, Git Bash)
curl -sSL https://cli.dailybot.com/install.sh | bash

# Entorno Python aislado con pipx
pipx install dailybot-cli

# O con pip
pip install dailybot-cli

# Verificar
dailybot --version

Guardar DAILYBOT_API_KEY de forma segura

Nunca committees DAILYBOT_API_KEY al código. Todo vendor de arriba trae manejo nativo de secretos — GitHub secrets, GitLab variables masked/protected, CircleCI contexts, Kubernetes secrets, EnvironmentFile= de systemd para cron. Rota la llave desde tu dashboard de Dailybot en el momento en que una credencial compartida sale del org.