Senate

CI/CD Integration

Automate deployments with webhooks

CI/CD Integration

Automate your deployments by integrating Senate with your CI/CD pipeline using webhooks.

Overview

Senate supports automated deployments through Webhooks - trigger deployments via HTTP POST requests.

Setting Up Webhooks

The easiest way to set up CI/CD is using GitHub's built-in webhook feature:

Get the Webhook URL

  1. Go to Services → Select your service
  2. Click Settings tab
  3. Copy the Webhook URL

Webhook URL in service settings

Configure GitHub

  1. In your GitHub repository, go to SettingsWebhooks
  2. Click Add webhook
  3. Paste the Senate webhook URL
  4. Set Content type to application/json
  5. Choose Just the push event or select specific events
  6. Click Add webhook

GitHub webhook configuration

Now every push to your repository will automatically trigger a deployment.

Keep your webhook URL secret. Anyone with this URL can trigger deployments.

Webhook URL Format

Each service has a unique webhook URL:

https://senate.example.com/api/services/<service-id>/deploy?token=<secret-token>

Manual Trigger

You can also trigger deployments manually via curl:

curl https://senate.example.com/api/services/<service-id>/deploy?token=<secret-token>

Troubleshooting

Webhook not triggering

  1. Check webhook URL is correct
  2. Verify network connectivity (can GitHub reach your Senate instance?)
  3. Check Senate logs for errors
  4. Ensure webhook is enabled in service settings

Deployment stuck

  1. Check image can be pulled
  2. Verify container starts successfully
  3. Check health check isn't failing
  4. Review deployment logs in Senate dashboard

Advanced: GitHub Actions Workflows

For more control over your deployment pipeline (e.g., running tests, building images before deploy), you can use GitHub Actions workflows.

Basic Deployment

Create .github/workflows/deploy.yml:

name: Deploy to Senate

on:
  push:
    branches: [main]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Trigger deployment
        run: |
          curl ${{ secrets.SENATE_WEBHOOK_URL }}

With Docker Build

Build and push image, then deploy:

name: Build and Deploy

on:
  push:
    branches: [main]

jobs:
  build-and-deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      
      - name: Login to Docker Hub
        uses: docker/login-action@v3
        with:
          username: ${{ secrets.DOCKERHUB_USERNAME }}
          password: ${{ secrets.DOCKERHUB_TOKEN }}
      
      - name: Build and push
        uses: docker/build-push-action@v5
        with:
          push: true
          tags: myuser/myapp:${{ github.sha }}
      
      - name: Deploy to Senate
        run: |
          curl "${{ secrets.SENATE_WEBHOOK_URL }}

Environment-Specific Deployments

Deploy to different environments based on branch:

name: Deploy

on:
  push:
    branches:
      - main
      - develop

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Deploy to staging
        if: github.ref == 'refs/heads/develop'
        run: curl ${{ secrets.SENATE_STAGING_WEBHOOK }}
      
      - name: Deploy to production
        if: github.ref == 'refs/heads/main'
        run: curl ${{ secrets.SENATE_PROD_WEBHOOK }}

Setting Up GitHub Secrets

  1. Go to your GitHub repo → SettingsSecrets and variablesActions
  2. Click New repository secret
  3. Add SENATE_WEBHOOK_URL with your webhook URL

Manual Approval for Production

For production deployments requiring approval:

jobs:
  deploy-prod:
    runs-on: ubuntu-latest
    environment: production  # Requires approval
    steps:
      - run: curl ${{ secrets.SENATE_PROD_WEBHOOK }}

On this page