Can GitHub Flow be used for deploying to Development, Staging, and Production? #196024
Replies: 3 comments
-
|
Hi @Rod-at-DOH , The short answer is Yes, absolutely. You can 100% use GitHub Flow while maintaining separate Development, Staging, and Production environments. In fact, forcing your branching strategy to match your infrastructure environments is a very common misconception. GitFlow ties environments to branches (dev branch \rightarrow dev env, staging branch \rightarrow staging env), whereas GitHub Flow ties environments to deployment pipelines and releases driven by the main branch. Here is how you can pitch this to your team and practically implement GitHub Flow across Dev, Staging, and Prod: 🛠️ How GitHub Flow Maps to Multiple Environments 1. The Development Environment Triggered by Pull Requests
2. The Staging Environment Triggered by Merges to Main
3. The Production Environment Triggered by Releases/Tags To deploy from Staging to Production without creating a production branch, you use GitHub The Flow: When you are ready to push to Production, you cut a new Release (e.g., v1.2.0) from the main branch. This action triggers the Production deployment pipeline. Alternative Continuous Deployment: If your automated testing is highly mature, merging to main can automatically deploy to Staging, run smoke tests, and automatically promote to Production after a manual approval checkpoint in GitHub Actions. 💡 Features to Help You Bridge the Cultural Gap GitHub Environments: In your repository settings, you can define three distinct Environments: Development, Staging, and Production.
🎯 The Last-Ditch Pitch to Your Team: GitHub Flow combined with GitHub Environments gives your team the best of both worlds: the simplicity of a single main branch and the strict control required for enterprise environments. |
Beta Was this translation helpful? Give feedback.
-
|
Hey @Rod-at-DOH Dev environment => triggered when a PR is opened from any feature branch So main stays clean and is always your single source of truth. No painful merge conflicts between long-lived branches, no GitFlow tax. |
Beta Was this translation helpful? Give feedback.
-
|
Short answer: yes, and that's actually how most teams running GitHub Flow at scale do it. The trick is decoupling branching strategy from deployment strategy — those are two separate things and Git Flow conflates them. In GitHub Flow you have one long-lived branch ( A common mapping that works well:
Why this is better than Git Flow's
The piece your colleagues are probably missing: Environments Repo → Settings → Environments → create Then in the workflow: jobs:
deploy-dev:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
environment: development
runs-on: ubuntu-latest
steps: [...]
deploy-staging:
if: github.event_name == 'release'
environment: staging
runs-on: ubuntu-latest
steps: [...]
deploy-prod:
needs: deploy-staging
environment: production # this gates on manual approval
runs-on: ubuntu-latest
steps: [...]
On the cultural side The reason GitHub Flow doesn't stick at a lot of orgs isn't technical, it's that "we have dev/staging/prod" gets mentally collapsed with "we need a branch per environment". Separating those two conversations — "branches are about change isolation, environments are about deploy targets" — usually flips it. Show the team that |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
🏷️ Discussion Type
Question
💬 Feature/Topic Area
Workflow Deployment
Discussion Details
I've known about GitFlow and GitHub Flow for about two years now. But as time goes by, I understand both of them better than I did when I first learned about them.
Git Flow strikes me as an approach that would work well, if your company's approach is to always maintain a Development, Staging, and Production branches. When I work, we've been using GitHub Enterprise in our GitHub Organizations for 3 years, but we really haven't done this rigorously. Another thing which has been in place here for many years is having a Development, Test (or Staging), and Production environment. These haven't been enforced using repos with appropriately named branches. It's just been an approach which has been followed long enough that it's been in place before I was hired.
Then there is GitHub Flow, which is simpler and cleaner. Personally, I prefer this approach. I like the idea of having just one, long-lived branch, the default branch. Then as many feature branches as you need, but they all should (ideally) go away once they've been merged back in main. And I've been championing this approach for a long time, but it really hasn't been adopted where I work. I don't think people have understood GitHub Flow. Perhaps I haven't done a good enough job explaining it. But now I'm wondering if a big part of it is because the cultural mindset is we must always have a development, staging, and production environment. And without realizing it until now, the GitFlow approach seems better suited to the cultural approach followed here since time began (at least here).
But, as one last ditch effort to try and get GitHub Flow adopted, I'm wondering if a GitHub Flow branching and project management approach could still be used to deploy to Development, Staging, and Production environments?
Beta Was this translation helpful? Give feedback.
All reactions