Salesforce Continuous Integration with GitHub Actions

After 6 months in the wait list, GitHub Actions (v2) finally came to my account. It’s a built-in CI/CD service for GitHub. I quickly tested it and I found it pretty good tool for GitHub users to start CI easily.

In this post, I’ll show a simple example to realize continuous integration for Salesforce development. When a pull request is created, the following tasks will be automatically executed.

Initial setup

Create a connected app and a private key for JWT flow. Follow the steps in the Trailhead project.

Save secrets

Store the consumer key of connected app as SALESFORCE_CONSUMER_KEY to repository secret. I also store secret key directly as SALESFORCE_JWT_SECRET_KEY. Or, you can store the decryption key and IV for encrypted secret key in the repository. And store the username of DevHub as SALESFORCE_DEVHUB_USERNAME.

Define workflow

Define workflow in .github/workflows/main.yaml. For more information about workflow syntax, see Workflow Syntax for GitHub Actions

Highlights

See how it works

Now you can easily and effectively review the pull request using the scratch org automatically created and tested.

Next step is to delete the scratch org after the pull request is merged/closed. We need to store the org username somehow.

I like GitHub Actions from many views. Tightly-coupled with the repository (infinite possibilities to integrate with the repository!). Concurrency. Supporting multiple OS. Various 3rd party actions.

I hope more and more Salesforce developers try GitHub Actions. Share if you create an awesome action!

Written on Aug 24, 2019.

comments powered by Disqus