Auto PR + Auto Deploy workflow using CI/CD Pipline This article describes a production-style automated workflow using GitHub Actions that creates a pull request automatically when a feature branch is pushed, runs continuous integration checks (tests and linting) before merging, and then automatically deploys the application to production (using Vercel for frontend and Render for backend) once the PR is merged to the main branch. The setup includes branch protection rules, required secrets for deployment tokens, and a final architecture that ensures only clean, tested code reaches production. Here’s a real production-style Auto PR + Auto Deploy workflow using GitHub Actions. This is the kind of setup used in teams to keep main stable and deployments automatic. We’ll build it in 3 parts: plaintext id="flow1" feature branch push ↓ Auto PR created GitHub Action ↓ CI runs tests, lint ↓ PR merged to main ↓ Auto deploy to production --- 🤖 1. Auto Create Pull Request Workflow This automatically creates a PR when you push a feature branch. 📁 .github/workflows/auto-pr.yml yaml id="pr1" name: Auto Create Pull Request on: push: branches-ignore: - main jobs: create-pr: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 - name: Create Pull Request uses: repo-sync/pull-request@v2 with: destination branch: main github token: ${{ secrets.GITHUB TOKEN }} pr title: "Auto PR: ${{ github.ref name }}" pr body: | 🤖 Auto-generated PR Branch: ${{ github.ref name }} Please review changes before merging. feature/login feature/login → main This ensures only clean code gets merged. .github/workflows/ci.yml yaml id="ci1" name: CI Checks on: pull request: branches: main jobs: test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Setup Node uses: actions/setup-node@v4 with: node-version: 20 - name: Install dependencies run: npm install - name: Run lint run: npm run lint - name: Run tests run: npm test --- 🧠 What this does: Before merge: Runs lint checks Runs tests Blocks bad code from merging --- 🚀 3. Auto Deploy on Merge to Main This deploys your app when PR is merged. 📁 .github/workflows/deploy.yml Example: Deploy React + Node Vercel + Render yaml id="deploy1" name: Auto Deploy on: push: branches: main jobs: deploy-frontend: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Install frontend working-directory: client run: npm install - name: Build frontend working-directory: client run: npm run build - name: Deploy to Vercel run: npx vercel --prod --token=${{ secrets.VERCEL TOKEN }} deploy-backend: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Install backend working-directory: server run: npm install - name: Deploy backend Render webhook run: curl -X POST ${{ secrets.RENDER DEPLOY HOOK }} Go to: 👉 Repo → Settings → Secrets → Actions Add: plaintext id="sec1" VERCEL TOKEN=your vercel token RENDER DEPLOY HOOK=https://api.render.com/deploy/xxx --- 🧭 5. Full Workflow in action Developer flow: plaintext id="flow2" git checkout -b feature-login git push origin feature-login In GitHub: Settings → Branches → main Enable: yaml id="notif1" bash id="tag1" git tag v1.0.0 git push origin v1.0.0 --- ⚠️ Common mistakes ❌ Auto-deploy without tests → leads to broken production ❌ No branch protection → anyone can push to main ❌ Missing secrets → deployment fails silently --- 🧠 Final Architecture Pro level plaintext id="final1" Feature Branch ↓ Auto PR Created ↓ CI tests + lint ↓ Review + Approval ↓ Merge to main ↓ CD Pipeline ↓ Frontend deploy Vercel Backend deploy Render/AWS ↓ Slack/Discord notification