Skip to content
Latchkey

How to Map CI to GitFlow Branches

GitFlow uses five branch types; CI must trigger different pipelines per type, from test-only on feature branches to production deploy on main.

GitFlow separates feature/*, develop, release/*, hotfix/*, and main. Each maps to a CI intent: test on feature and develop, build a candidate on release, deploy to production on main. Use branch filters to route the right jobs.

Branch to CI mapping

BranchTriggerCI intent
feature/*push, PR to developlint + unit tests
developpushfull test + deploy to staging
release/*pushbuild release candidate + integration tests
hotfix/*pushtest + fast-track to production
mainpush (merge)deploy to production, tag release

Workflow

.github/workflows/ci.yml
on:
  push:
    branches: [develop, main, 'release/**', 'hotfix/**']
  pull_request:
    branches: [develop]
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: npm ci && npm test
  deploy-staging:
    needs: test
    if: github.ref == 'refs/heads/develop'
    runs-on: ubuntu-latest
    steps:
      - run: ./deploy.sh staging
  deploy-prod:
    needs: test
    if: github.ref == 'refs/heads/main'
    runs-on: ubuntu-latest
    steps:
      - run: ./deploy.sh production

Gotchas

  • GitFlow adds ceremony; for continuous delivery, trunk-based or GitHub Flow is usually simpler.
  • Keep hotfix and release branches short-lived to avoid painful merge-backs into develop.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →