How to build a Salesforce CI/CD pipeline using GitHub

How to build a Salesforce CI/CD pipeline using GitHub

Holly White on

Share with


Adopting version control is a fundamental part of Salesforce DevOps. There are many distributed version control systems available but the most widely used in the Salesforce ecosystem is Git, with GitHub as the preferred repository hosting tool. For those who have already implemented version control with GitHub and are running reliable deployments through a source-driven workflow, the next step is to add automation.

If this feels like a big jump, Gearset is here to help. In this post we’ll look specifically at GitHub and how it integrates with Gearset to build an automated Salesforce deployment pipeline. And, you’ll see how easy it is to get started with Gearset’s Pipelines to automatically deploy your metadata from your GitHub repository.

Benefits of version control and CI/CD

Version control is an important part of Salesforce DevOps. Utilizing a version control system, such as Git, enables you to efficiently make, merge, and monitor changes without the risk of overwriting each other’s work. It also allows you to easily rollback deployments to previous versions and increase collaboration across the entire team.

You can customize your branching strategy to fit your team. For example, commit to short-lived feature branches then merge into main (feature-based development), or merge feature branches into a release branch and merge to main on a set cadence. These are just two types of strategy you can choose from.

Once version control is well established as your source of truth, and your deployments are repeatable and reliable, you can begin to automate your pipeline by using continuous integration and continuous delivery (CI/CD). The benefits of automation include speeding up testing processes and catching issues early by constantly merging code changes into shared environments.

Continuous integration (CI) focuses on automatically progressing work along the release pipeline, so that new work can be integrated into shared environments and tested quickly. This encourages rapid feedback loops and means the developers’ work on a feature branch can be quickly merged onto a shared branch, a sandbox environment for testing, or to live environments. Continuous delivery (CD) focuses on releasing small slices to live environments, to deliver value to end users as quickly as possible. The overall goal of CI/CD is to close feedback loops and streamline the entire release process — saving time and money.

Can we build a CI/CD pipeline with generic tools?

It’s not easy to build an automated pipeline in GitHub for your Salesforce release management process. You’ll need to use an automation/orchestration tool to fetch the Salesforce DX project from the repo and then use the SFDX CLI to run commands to build your project. You can do this locally with a tool like VSCode.

Building this kind of CI/CD pipeline is a very manual and expensive process and will need constant maintenance once built. Without this upkeep, something can break unexpectedly — especially if there are big changes in a Salesforce release or something is released into an environment that you weren’t expecting.

Why GitHub?

With over 100 million users, GitHub is the world’s largest version control host on the market today. While there are other options out there — like Bitbucket, AWS CodeCommit, Azure DevOps, and GitLab — GitHub is the system that most teams are using to track their metadata changes in Salesforce.

The benefits of GitHub:

  • Widely known so teammates will likely know how to use it
  • Manage and track changes to your Salesforce code and configuration
  • Collaborate with teammates on code reviews
  • Automation capabilities offered through GitHub Actions or a third-party platform
  • Store and maintain project documentation alongside the code
  • Has cloud-hosted options as well as offering on-premises hosting with GitHub Enterprise
  • Security options like code scanning and access control on repositories and branches
  • Fits with your existing tech stack thanks to a huge amount of integration options
  • Has an active community of support and advice

How does Gearset integrate with GitHub?

Gearset supports all the Git-based providers mentioned above (and more!), but in this walkthrough we’ll be looking at how to set up your Salesforce pipeline in Gearset, using GitHub. You can sign up for a free 30-day trial of Gearset and follow along with these steps.

It’s really easy to hook up your GitHub repo to Gearset.

In Gearset, go to the Source control and services page and click + Connect to GitHub.

You’ll be taken to GitHub’s OAuth page for authentication.

Connect Gearset to your GitHub repository.

Once complete, you will be redirected back to Gearset and you should now be able to use GitHub branches as your source or target — which you can confirm with Compare and Deploy.

Your source control is now connected to Gearset.

Build your CI/CD pipeline with Gearset

Once you’re all set up and have connected your GitHub with Gearset, it’s time to get hands on with Gearset’s Pipelines.

Add a new pipeline

Select Continuous Integration from the left hand side menu. In the top right, click Pipelines and then Add new pipeline using the +.

Add a new pipeline.

Add webhook

Click Add webhook and Gearset will automatically create one for you. You can also manually set one up. The webhook allows Gearset to sync in real time with your Git repositories and branches.

Add a webhook.

Create new environment

Next, click Create environment and then select Create new environment/job. Follow Gearset’s CI job wizard through the next steps to configure your job.

Add your first environment.

Add more environments

Add as many environments as you need, clicking + Add environment in the top right.

Keep adding your environments for the pipeline.

Edit and link your environments

Once you’ve added your environments, and any sandboxes you need, click Edit environments in the top right corner and arrange your environments in order.

After arranging your environments, link them together by dragging the circles to the next environment in the pipeline. When you’re happy, click Save changes.

Link up your environments in the correct order.

Your first GitHub pipeline is done!

You’ve just set up your first CI/CD pipeline using GitHub with Gearset! Now Gearset is in a position to work alongside GitHub and allow the creation of feature branches, raising pull requests, and automatically promoting your Salesforce changes as you merge into each environment, giving you an all encompassing CI/CD workflow.

Get started today!

Building a reliable CI/CD pipeline for Salesforce with GitHub Enterprise doesn’t have to be difficult, thanks to Gearset’s Pipelines. To see Pipelines in action, take a look at this video recording, or book a demo with our DevOps experts.

Ready to get started with Gearset?