Skip to content

Latest commit

 

History

History
109 lines (76 loc) · 2.74 KB

File metadata and controls

109 lines (76 loc) · 2.74 KB

GitHub Webhook & EC2 Deployment Setup

GitHub webhooks push repository events to this service in real time. On EC2 you have a real public IP — no tunnel needed.


1. EC2 Prerequisites

  1. Instance: Ubuntu 22.04+, t3.micro or larger
  2. Security Group — inbound rules:
    Port Protocol Source Purpose
    22 TCP Your IP SSH
    8080 TCP 0.0.0.0/0 App (HTTP)
  3. Install Docker + Compose:
    curl -fsSL https://get.docker.com | sh
    sudo usermod -aG docker ubuntu
    sudo apt-get install -y docker-compose-plugin
    newgrp docker

2. Deploy the service

# Clone / copy project to EC2
scp -r ./github-integration ubuntu@<EC2-PUBLIC-IP>:~/github-integration

# SSH in
ssh ubuntu@<EC2-PUBLIC-IP>

cd ~/github-integration

3. Update config.yaml on EC2

Replace all localhost references with your EC2 public IP or DNS:

server:
  port: 8080

github:
  oauth_redirect_url: http://<EC2-PUBLIC-IP>:8080/   # frontend landing page

webhook:
  app_url: http://<EC2-PUBLIC-IP>:8080
  secret: your-shared-webhook-secret                  # pick any string

internal:
  service_key: your-internal-service-key

Use Elastic IP in AWS for a stable address that won't change on restart.


4. Update GitHub OAuth App

In your GitHub OAuth App settings (github.com → Settings → Developer settings → OAuth Apps):

  • Homepage URL: http://<EC2-PUBLIC-IP>:8080
  • Authorization callback URL: http://<EC2-PUBLIC-IP>:8080/

5. Start the service

cd ~/github-integration
make up        # starts postgres, redis, rabbitmq, app
make migrate   # run DB migrations
make logs      # tail logs

6. Register the webhook on GitHub

  1. Open the target repository → Settings → Webhooks → Add webhook
  2. Payload URL: http://<EC2-PUBLIC-IP>:8080/api/webhooks/github
  3. Content type: application/json
  4. Secret: same value as webhook.secret in config.yaml
  5. Events: ✅ Pull requests only
  6. Save

7. Verify

  • GitHub → repo Settings → Webhooks → Recent Deliveries → expect 202 Accepted
  • On EC2: make logs → look for:
    level=INFO msg="webhook received" event=pull_request action=opened
    level=INFO msg="email notification" to=user@example.com subject="PR #1 opened: ..."
    
  • Use Redeliver button in GitHub webhook UI to replay an event without creating a new PR.

Notes

  • No real email is sent — notifications are logged to stdout (check make logs)
  • Webhook registration is per-repo and manual
  • To wipe all data and start fresh: make down-clean && make up && make migrate