A Git-based workflow from dev to deploy

DDEV + Git

It can be a challenge to get frequent and finite changes to web projects from concept to commit to deployment on your hosting platform. The work must be tracked to facilitate collaboration, accuracy, and accountability, and the deployment pipelines maintained, standardized, and sustainable. Using a version control system such as Git to track work is the standard for development teams today, but connecting a Git repository into every step in an end to end workflow requires time to configure and manage. It might feel complex and intimidating, but with some patience and a little assistance from DDEV-Live you can save a lot of time and stress.

DDEV-Live is our hosting platform, which not only connects to— and in fact relies on— your project’s Git repository, but also allows you to work with atomic deploys, CI/CD workflows, and many other tools and services you may already be using. With automated deploys as a standard feature and room for customization, it’s possible to get those small pieces of work through the pipeline to staging and production quickly and accurately, every time. 

Using Git in your development workflow

Git is a free and open source distributed version control system used by many of us to collaborate and develop both open source and proprietary software. Every project has its own Git repository, which must be hosted somewhere, often GitHub, GitLab, BitBucket, etc. Our own open source projects at DDEV are shared on GitHub, such as the DDEV-Local development environment. 

While there is generally a central repository all work goes into, multiple streams of work can happen simultaneously, be merged without conflict, and you can track source code as well as static files. As Tag1’s Greg Lund-Chaix said in his recent session on Git and DDEV-Local: always work in a feature branch, pull the latest changes before you add your commit, and no editing on the server! It’s much easier to understand changes when everyone has been making small commits over time in clearly named branches which have been cleanly merged into the main branch of the repository.

Branches also allow you to contain and deploy discrete chunks of work based on the same codebase. For example, a set of new commits to a branch named “testing” can be deployed to a test server while the main “production” branch remains untouched on the production server. Or, a group of changes can be combined and tagged “myproject version 2.0” to capture that moment in development for future reference. 

So, you’re on board and set up with Git in general? You may be seeing some success with automation and the use of Git for version control but it’s been difficult to connect all the pieces and get the entire team into the workflow. To really start smoothing the wrinkles from development to deployment, it’s time to add DDEV-Live. 

Deploy from Git to DDEV-Live 

DDEV-Live is a modern hosting platform, built from the ground up on open source and cloud native principles. When you connect your DDEV-Live account to your Git provider, DDEV-Live watches for changes in your designated repositories and automatically deploys when a new commit is detected. That’s the out of the box, simple way to use DDEV-Live and Git. 

You can also integrate the DDEV-Local development environment with DDEV-Live in a similar fashion, passing code through Git. For continuous integration and continuous delivery, you can start adding in additional tools using your DDEV-Live API token. Follow the tutorials for CircleCI or Jenkins integrations, or just use them as inspiration for your own custom workflow. When an action or trigger is recognized by the DDEV-Live platform a new atomic (or zero down time) deployment can be initiated, including the creation of a fresh new container in Kubernetes (the underlying system in DDEV-Live). 

This allows you and your team to take full advantage of Git, creating as many branches and tags as required. You can now set up a workflow to run tests, stage new work, and cut a release to push a new chunk of code. With one code base, we can track many deploys and versions, dependencies via composer, and configurations stored per environment. It’s very granular but connected to that one code base. The hosting industry is moving in this direction, using triggers to create and manage complex or simple workflows that the hosting platform is “aware” of.

This Git-based workflow also supports one of the core concepts behind DDEV, the “12 factor app.” For example, Factor #9 is disposability: We are not just creating a new build, we are creating a fresh new container for each new build or site. Or Factor #10, parity between development and production: Especially by working with DDEV-Local and configuring your development environment, you can be certain that your project does work exactly the same in production. Add in a staging environment on DDEV-Live for extra assurance, deployed from a branch named “staging” perhaps, and you’re well on the way to an efficient, safe, sustainable deployment workflow.

Safe deployments and freedom for developers

It sounds like a lot, but by using Git to track your project through distributed development instances and DDEV-Live for automated, tagged deployments, you can save the time and manual work of shepherding changes through your release pipeline. The sense of safety and stability generated by automatically building testing and staging environments, or even to reverting changes via Git-based workflows can mean greater innovation and freedom for developers to explore and experiment, achieving more, more easily.

Take a little time to create a test project or copy an existing project into a new hosted Git repository so you can try out DDEV-Live and see the possibilities for your project. Whether you want to connect an existing workflow or finally start using some of the best practices you’ve heard about, there’s a free 10 day trial so you can see how DDEV-Live can support your work. 

Thanks to Jason Roberts, Elli Ludwigson and Steve Grandchamp for collaborating on this blog.

Share this post: