This project demonstrates how to set up a Webhook to receive GitHub events using Flask, store the data in MongoDB Atlas, and deploy it on an AWS EC2 instance.
a) Python
b) MongoDB Atlas
c) GitHub Webhooks
d) AWS EC2 Instance
e) Git & GitHub
webhook-repo/
├── main.py # Flask app to receive GitHub events
├── requirements.txt # Python dependencies
├── .github/
│ └── workflows/
│ └── webhook.yml # GitHub Actions workflow
-
Clone the Repository -
git clone https://github.com/your-username/webhook-repo.git cd webhook-repo
-
Install Dependencies -
pip install -r requirements.txt
-
MongoDB Atlas Setup -
a) Create a MongoDB Atlas account.
b) Create a cluster and user.
c) Replace the Mongo URI in app.py:
uri = "mongodb+srv://<username>:<password>@cluster1.mongodb.net/?retryWrites=true&w=majority"
-
Run Flask Server :
python app.py
-
Deploy to AWS EC2 :
a) Launch an EC2 instance.
b) EC2 instance connect.
c) Install Python and Git.
d) Clone the repo and run the Flask app.
e) Open port 5000 or 80 in EC2 security group.
-
Go to your GitHub repository ➝ Settings ➝ Webhooks ➝ Add Webhook
-
Payload URL: http://:5000/webhook/receiver
-
Content type: application/json
-
Events: Push, Pull Requests (or all)
-
Click Add Webhook
-
Receives real-time GitHub event data.
-
Saves event data into MongoDB.
-
Designed for learning and demonstration purposes.