Your Software
Faster without Risk

FeatBit, a Fast & Scalable Open Source Feature Flags Management Tool built with .NET; Ideal for Self Hosting.

Innovate Your Software Faster without Risk

A Fast, Scalable, and Open-source Feature Flags Management Service. For Cloud & Self-hosting.

How to Integrate Feature Flags with GitHub for Efficient Development Workflows?

Last updated date:


Feature Flags is a software development technique that enables developers, as well as Product Managers, QAs, and Customer Success teams, to activate or deactivate features for specific target audiences in an application without deploying new code. This technique is a powerful tool for controlling the release of new features, managing risks, and ultimately enhancing the quality of your software.

In this article, we will explore how to integrate Feature Flags with GitHub to streamline development workflows. We'll cover this through three key steps:

  • How Feature Flags Enhance Git Branching Strategies and Workflows
  • How to Enhance Feature Release Workflows with GitHub Actions
  • Using Feature Flags to Avoid Git Rollbacks in Production.

How Feature Flags Enhance Git Branching Strategies and Workflows

Git branching strategies are a set of rules that define how developers should use Git branches in their projects. They are used to manage the development process and ensure that all changes are tracked and tested before being merged into the main branch. In the evolving landscape of software development, managing feature releases and workflow efficiency is paramount. Feature flags have emerged as a game-changing technology, extending and enhancing traditional Git branching strategies.

Traditional Git Branching

Git branching is a core component of many development workflows. It involves creating separate branches for new features, bug fixes, or experiments. While effective, this approach has limitations, particularly when it comes to managing multiple features in development simultaneously and integrating them into the main codebase.

Bridging the Gap with Feature Flags

Using Feature flag management tools for managing the release of new features in your application. They allow you to toggle certain features on or off for specific users or groups. This is especially useful when you want to test a new feature with a limited audience before releasing it to everyone. Additionally, they can be used to roll back changes if an update causes problems. Importantly, this occurs in production and can be done without any code changes.

Feature flags can significantly enhance Git branching strategies in several ways:

  1. Simplified Branch Management

With feature flags, the need for long-lived feature branches diminishes. Developers can merge code into the main branch early and often, even if the feature isn't ready for release. This reduces merge conflicts and simplifies branch management.

  1. Controlled Feature Release and Git Branching

In a typical Git workflow without feature flags, releasing a new feature often requires merging a feature branch into the main branch and deploying. This process can be risky, especially for large features or changes, as it's an all-or-nothing approach. Feature flags, when integrated with Git branching, allow for a more controlled release:

  • Gradual Rollout: Even after merging a feature branch into the main branch, the feature can be enabled for a subset of users. This approach decouples deployment from release, allowing for more controlled and safer feature introductions.
  • Branching for Experiments: Developers can use short-lived branches for experiments and merge them into the main branch for testing in production with a limited audience. This method reduces the complexity of managing multiple long-lived branches.
  1. Faster Feedback Loop and Git Branching

In traditional Git branching, feedback on new features usually comes late in the development cycle, often after the feature branch is merged and deployed. Feature flags enhance this by:

  • Immediate Testing in Production: With feature flags, new features merged into the main branch can be tested immediately in a production environment by enabling them for specific users or contexts. This provides real-time feedback and quicker iterations.
  • Simplifying Testing Branches: Developers can test features directly in the main branch under different flag conditions, reducing the need for multiple testing branches.
  1. Risk Mitigation and Git Branching

Risk mitigation with feature flags directly impacts how branches are managed in Git:

  • Reducing Rollback Complexity: If a new feature causes issues post-deployment, instead of reverting commits or rolling back merges, the feature can be turned off via the feature flag. This avoids the complexities and risks associated with Git rollbacks.
  • Safe Integration of Features: Features developed in branches can be merged into the main branch more safely. Even if a feature isn't fully ready or tested, its incomplete parts can be hidden behind a feature flag, ensuring the main branch remains stable.
  1. Facilitating Trunk-Based Development

Trunk-based development (TBD) is a branching strategy where developers work on a single branch (the 'trunk'). Feature flags complement TBD by allowing unfinished or experimental features to be merged into the trunk without impacting the overall functionality.

In summary, Feature flags represent a significant advancement in software development practices, offering a flexible and efficient complement to traditional Git branching strategies. By incorporating feature flags, teams can enjoy streamlined workflows, faster time-to-market, and a reduced risk profile, ultimately leading to higher quality software and improved user satisfaction. In the ever-evolving world of software development, the integration of feature flags with Git branching strategies is not just an option; it's a necessity for agile, responsive, and efficient development.

How to Enhance Feature Release Workflows with GitHub Actions

The Pain Point:

In traditional CI/CD setups, a significant challenge arises when developers only have the ability to check or examine feature flags in the code repository. Without real-time awareness of the current values and states of these flags, there's a gap in the deployment pipeline. This disconnect can lead to inconsistencies in deployment and release stages, potentially hindering effective trunk-based development. For example, in a scenario where GitHub Actions are used for continuous delivery, new pull requests could inadvertently trigger deployments that don't align with the intended targeting rules or dynamic requirements.

The Solution:

To address this, we can try to introduce a new DIY Feature Management method in GitHub Actions. This method enhances the deployment pipeline by allowing actions to evaluate the values of feature flags in real-time: When an action is invoked, it checks for specified flags and returns their values, which can be used in various ways. This integration significantly improves the decision-making process in CI/CD pipelines.

For example, consider the following job configuration in a GitHub Actions workflow:

  name: Feature Flag Evaluation
  runs-on: ubuntu-latest
    output1: ${{steps.flag-evaluation.outputs.flag-value}}
      name: Evaluate Feature Flags
      id: flag-evaluation
      uses: [GitHub Action for Feature Flag Evaluation]
        api-key: ${{ secrets.API_KEY }}
        flags: flag-name

This job retrieves the value of a specific flag (e.g., 'flag-name') and stores it in 'output1'. This value then determines if subsequent jobs or steps should run. For example:

if: needs.flag-eval-job.outputs.output1 == 'dev-build'
  name: Build and Push
  uses: docker/build-push-action@v4
  # ... additional configuration ...

This conditional execution offers developers the capability to use feature flags to control parts of their GitHub Actions. It adds a layer of safety, preventing accidental builds from pull requests and fostering a trunk-based development approach.

Additionally, the integration can retrieve flag values for dynamic use in action jobs/steps. For example, setting environment variables during a Docker build, regional parameters in infrastructure provisioning, or applying specific tags in software installations.

Context Targeting: I recommend that the integration should also supports context targeting. By default, when this Action is triggered, GitHub sends context kinds (e.g., repository name, user information) which can be used for sophisticated targeting rules in your CI/CD process.

In summary, this suggested feature for GitHub Actions resolves the critical issue of real-time feature flag evaluation, enhancing the reliability and dynamism of CI/CD pipelines.

Using Feature Flags to Avoid Git Rollbacks in Production

After deploying to production, if any issues are found, the traditional way is to roll back the code to the previous version. This scenario is very common in software development. However, rolling back safely can be challenging. It's crucial to ensure that no data is lost and that nothing else is disrupted in the process. So, how can we accomplish this safely? The answer lies in Feature Flags.

Feature Flags are a method to control the release of new features in your application. They allow you to toggle certain features on or off for specific users or groups. This is especially useful when you want to test a new feature with a limited audience before releasing it to everyone. Additionally, they can be used to roll back changes if an update causes problems. Importantly, this occurs in production and can be done without any code changes.

if (featureFlags.isFeatureReleased('new-feature')) {
    // Execute new feature code

As illustrated in the code above, when a new feature is released and exceptions (or errors) are detected, you simply need to disable or roll back the feature flag remotely. The function featureFlags.isFeatureReleased('new-feature') will then return false, preventing the new feature from being executed. This provides a straightforward and safe way to roll back code in production, in real-time, without modifying the code.

This method does not require any code changes. After resolving the issue, you simply redeploy the updated code and activate the feature flag again. The new feature will then be executed once more. This approach allows development teams to mitigate the risk of disrupting the production environment, ensuring greater peace of mind.

The image above shows an example of how to use a UI to toggle on/off or roll back a problematic feature.

Key words: Decouple Release from Deploy, Trunk based development, Testing in Production, Progressive Rollout


In conclusion, integrating with GitHub Feature Flags significantly revolutionizes development workflows. By enhancing Git branching strategies, streamlining feature release processes with GitHub Actions, and providing a safer alternative to traditional rollbacks in production, feature flags offer a level of dynamism and control previously unattainable. They enable a decoupled release-from-deploy approach, facilitate trunk-based development, allow testing in production, and support progressive rollouts. This integration not only mitigates risks but also accelerates time-to-market, ensuring that teams can respond swiftly to changing requirements while maintaining high-quality software delivery. Additionally, selecting an appropriate feature flag tool, particularly those that are open source feature flags, can significantly enhance your development efficiency and reduce costs.