A super simple but production-ready FastAPI project that deploys automatically to Render.com every time you push to GitHub, using GitHub Actions for true CI/CD.
- Python FastAPI app (with
/,/health, and/reverseendpoints) - Modern project structure (no frameworks or boilerplate, just code)
- Live deployment to Render – 100% free tier
- Automated CI/CD pipeline (push to main → instant deploy)
- Ready to extend with real business logic!
GET /– Welcome message (update to see CI/CD in action!)GET /health– Health check endpointPOST /reverse– Reverses text, example:{ "text": "YouTube" } ⇒ { "reversed": "ebuTuoY" }
git clone https://github.com/YOUR-USERNAME/fastapi-cicd-demo.git
cd fastapi-cicd-demo
pip install -r requirements.txtuvicorn main:app --reload- Browse to: http://localhost:8000
- Try
/docsfor Swagger UI!
- Go to render.com and log in or create an account
- Click New + > Web Service
- Connect your GitHub repo
- Use these settings:
- Build Command:
pip install -r requirements.txt - Start Command:
uvicorn main:app --host 0.0.0.0 --port 10000
- Build Command:
- Click Create Web Service
Wait ~1 minute for your app to build and go live.
- In your repo, create:
.github/workflows/deploy.yml
Copy the workflow from this repo. - On Render, go to your Service > Settings > Deploy Hooks
Copy your Deploy Hook URL. - On GitHub, go to Settings > Secrets and variables > Actions
- Add new secret:
RENDER_DEPLOY_HOOK= (Paste your Render Deploy Hook URL)
- Add new secret:
- Now, every push to main will trigger a new deploy!
fastapi-cicd-demo/
│
├── main.py # FastAPI app code
├── requirements.txt # Dependencies
└── .github/workflows/
└── deploy.yml # GitHub Actions workflow
from fastapi import FastAPI
from pydantic import BaseModel
app = FastAPI()
@app.get("/")
def hello():
return {"msg": "It works! Auto-deployed by GitHub Actions 🚀"}
@app.get("/health")
def health():
return {"status": "ok"}
class ReverseRequest(BaseModel):
text: str
@app.post("/reverse")
def reverse(req: ReverseRequest):
reversed_text = req.text[::-1]
return {"reversed": reversed_text}name: Deploy to Render
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Trigger Render deploy
env:
RENDER_DEPLOY_HOOK: ${{ secrets.RENDER_DEPLOY_HOOK }}
run: curl -X POST "$RENDER_DEPLOY_HOOK"- See a failed deploy?
Check the Render dashboard for build logs. - Workflow fails?
Make sure yourRENDER_DEPLOY_HOOKis set correctly in GitHub repo secrets.
- Add automated tests (pytest, httpx, etc.)
- Add Docker support
- Add more endpoints or auth
- Ask for help in Discussions or by creating an issue!
See the full step-by-step guide, including real CI/CD failures and fixes, on my YouTube channel:
👉 Learn with DevOps Engineer
All source code is included in this repo (or see the ZIP link below this video!).
Enjoy! If you found this helpful, star the repo and subscribe for more practical DevOps + Python guides!