GitHub Actions

You can easily integrate AlertHub into your GitHub Actions CI/CD pipelines to receive notifications when a build or test fails.

Implementation

Add a step to your .github/workflows/main.yml (or any workflow file) that runs only on failure.

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"
          }'

Security

Remember to add your ALERTHUB_KEY to your repository’s secrets/variables under Settings > Secrets and variables > Actions.