GitHub Actions

Puedes integrar AlertHub en tus pipelines CI/CD de GitHub Actions para recibir notificaciones cuando falle un build o un test.

Implementación

Añade un paso a tu .github/workflows/main.yml (o a cualquier archivo de workflow) que se ejecute solo si hay un fallo.

name: CI

on: [push]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      
      # Your build/test steps here
      - name: Run Tests
        run: npm test

      # AlertHub Notification on Failure
      - name: Send Alert to AlertHub
        if: failure()
        run: |
          curl -X POST 'https://api.thealerthub.com/sendAlert' \
          -H 'Content-Type: application/json' \
          -d '{
            "ah_key": "${{ secrets.ALERTHUB_KEY }}",
            "ah_title": "GitHub Action Failed",
            "ah_description": "Workflow ${{ github.workflow }} failed on branch ${{ github.ref }}.",
            "ah_level": "critical",
            "ah_source": "GitHub"
          }'

Seguridad

Recuerda añadir tu ALERTHUB_KEY a los secretos/variables del repositorio en Settings > Secrets and variables > Actions.