Automating Salesforce Deployment with GitHub Actions
Author
In today’s fast-paced development environment, automating deployment processes is crucial for efficiency. This guide outlines the steps to deploy Salesforce applications using GitHub Actions, streamlining the development workflow.
Here are the steps for Automating Salesforce Deployment with GitHub Actions.
Step 1: Configure Visual Studio Studio with GitHub.
Configure Visual Studio Code (VS Code) with GitHub integration for a seamless development experience. Ensure your Salesforce project is well-organized within VS Code.
- Begin by creating a new folder within your Visual Studio Code interface. Inside this folder, create a new file to work with.Begin by creating a new folder within your Visual Studio Code interface. Inside this folder, create a new file to work with.
- To confirm your Git version, access the terminal within VS Code and enter the command: git –version.
- Initialize a Git repository for your project by executing the command: git init in the terminal.
- Add your files to the staging area using the command: git add *. This prepares them for committing.
- Commit your changes with a descriptive message using the command: git commit -m “Initial Commit”.
- Establish a connection to your GitHub repository by first creating a repository on the GitHub platform. Once created, link your local repository to GitHub using the command: git remote add origin https://github.com/YourUsername/YourRepository.git, replacing “YourUsername” and “YourRepository” with your GitHub details.
- Push your committed changes to GitHub by executing the command: git push origin master in the terminal.
Step 2: Establish a Confidential Variable in GitHub.
- Enhance security by setting up a secret variable in your GitHub repository. Enhance security by setting up a secret variable in your GitHub repository.
- This ensures sensitive information, such as Salesforce credentials, is stored securely and is only accessible by authorized workflows.
Go to Repository Settings:
- Navigate to your GitHub repository. Click on the “Settings” tab. In the left sidebar, select “Secrets. “Click on “New repository secret.”Navigate to your GitHub repository. Click on the “Settings” tab. In the left sidebar, select “Secrets. “Click on “New repository secret.”
- Add Repository Secret: Enter a name for your secret, for example, `ACC_SFDX_URL`.
- Set the value to force://<clientId>:<clientSecret>:<refreshToken>@<instanceUrl>
- Replace the value `<clientId>`, `<clientSecret>`, `<refreshToken>`, and `<instanceUrl>` with the corresponding values.
Create a Connect App in the target Org.:
- Go to “Apps” in the Quick Find Box and select “App Manager.”Go to “Apps” in the Quick Find Box and select “App Manager.”
- Create a new Connected App.
- Provide a name for the app in the “Connected App Name” field and the contact email.
- Enable OAuth settings by checking the corresponding checkbox.
- Set the Callback URL to https://login.salesforce.com/.
- In “Selected OAuth Scopes”. Save your settings and click “Continue.”
- Retrieve Consumer Key and Secret: Navigate to “Manage Consumer Details” within the Connected App. Copy both the Consumer Key and Consumer Secret.
- Access OAuth Policies: In the “Connected App” section, go to “Manager” and select “OAuth Policies.”
Generate Refresh Token and Instance URL:
- Create a Salesforce app and perform a search. Access the authorization URL:Create a Salesforce app and perform a search. Access the authorization URL:
- https://<YOUR_INSTANCE>.salesforce.com/services/oauth2/authorize?response_type=code&client_id=<CONSUMER_KEY>&redirect_uri=https://login.salesforce.com/
- Allow access if prompted and copy the authorization code from the redirected URL.
Use Postman to Get Refresh Token:
- Use Postman to send a POST request to:Use Postman to send a POST request to:
- https://<YOUR_INSTANCE>.salesforce.com/services/oauth2/token?code=<CODE>&grant_type=authorization_code&client_id=<CONSUMER_KEY>&client_secret=<CONSUMER_SECRET>&redirect_uri=https://login.salesforce.com/
- Replace `<YOUR_INSTANCE>`, `<CODE>`, `<CONSUMER_KEY>`, `<CONSUMER_SECRET>` with the obtained values.
- A refresh token serves as a secret key, allowing you to obtain a new access pass seamlessly, eliminating the need to re-enter your password every time.
Retrieve Values:
- Once you have the refresh token, instance URL, clientId, and clientSecret, you can compose the complete value
- force://<clientId>:<clientSecret>:<refreshToken>@<instanceUrl>
Now, you can use this composed value as a secret in your GitHub Actions workflow, ensuring secure access to your Salesforce instance.
Step 3: Upload the GitHub Action File to GitHub.
Create a GitHub Actions workflow file in your project repository. This file will define the deployment workflow, specifying the actions to be taken during deployment. Commit and push this file to your GitHub repository.
- Begin by creating a folder named “. github” in your project directory.
- Inside the “.github” folder, create another folder named “workflows“.
- Within the “workflows” folder, create a YAML file named “salesforce.yml“.
- Below is the content you should include in the “salesforce.yml” file.
- Make sure to create variable ${{ secrets.ACC_SFDX_URL}} using step 2.
Step 4: Commit and Push Code to GitHub.
- Commit and push your Salesforce code changes to the GitHub repository. Commit and push your Salesforce code changes to the GitHub repository.
- GitHub Actions will automatically trigger the deployment workflow defined in the workflow file.
- Modify Code: Make changes to your Apex class or related files.
- Commit Changes: Record and save your modifications with a commit.
- Push to GitHub: Upload your changes to your GitHub repository.
- GitHub Action Triggers: Once pushed, a GitHub Action named DeployWithGitHubAction automatically starts.
- Automatic Deployment: DeployWithGitHubAction is configured to deploy changes to a target organization without manual intervention, streamlining the deployment process.
Step 5: Verify Your Code in the Target Organization
- Monitor the GitHub Actions workflow to ensure a successful deployment. Monitor the GitHub Actions workflow to ensure a successful deployment.
- Once completed, verify the changes in your Target Org to confirm the code has been successfully deployed.
Pranshu Goyal, Director of Products at Mirekta, states: “We envision DSM to be used by every small to a medium-sized organization dealing with bad data and want to get rid of duplicates easily with no cost. We have faced issues dealing with duplicates in our organization. That inspired us to make a solution that is not only simple to use but can be used widely to make the organization’s data clean to make them more efficient and productive. We want DSM to be a solution for every organization looking for duplicate management capability better than the Salesforce out-of-the-box solution with no additional cost.”
Recent Posts
-
Salesforce 2025 Game-Changing Trends You Need to Know28 Jan 2025 Blog
-
Agentforce 2.0: Everything You Need to Know About the Latest Update22 Jan 2025 Blog
-
The Ultimate Guide to NetSuite Development: Tools and Techniques10 Jan 2025 Blog
-
How Salesforce Nonprofit Cloud Transforms Fundraising Strategies10 Jan 2025 Blog
-
The Impact of Salesforce Development Partners on Small and Medium Businesses08 Jan 2025 Blog
-
Key Questions to Ask When Hiring a NetSuite Development Partner08 Jan 2025 Blog
-
Salesforce Agentforce Demystified: Your Essential Guide08 Jan 2025 Blog
-
Salesforce and NetSuite Integration: Driving Business Efficiency with Precision06 Jan 2025 Blog
-
Everest Group has positioned Mirketa as an Aspirant in the report24 Dec 2024 Press Release
-
Salesforce Einstein20 Dec 2024 E-Book
-
Order to Cash Cycle with NetSuite20 Dec 2024 E-Book
-
Empower Your Marketing Strategy with Salesforce Marketing Cloud's Automation Studio Activities13 Dec 2024 Blog
-
Salesforce CPQ for Subscription-based Businesses10 Dec 2024 Blog
-
Unleashing the Magic of Einstein Prediction Builder10 Dec 2024 Blog
-
Customized Templates and Branding with Salesforce Experience Cloud10 Dec 2024 Blog
-
Unleashing the Power of Real- Time Reports and Dashboards in NPSP10 Dec 2024 Blog
-
Top 4 Salesforce Automation Tools in 202409 Dec 2024 Blog
-
Salesforce Service Cloud Implementation: The Ultimate Guide09 Dec 2024 Blog
-
Salesforce CRM Implementation Partner Enhancing Automation in Healthcare09 Dec 2024 Blog
-
Shorten Your Sales Cycle in 8 Steps: Salesforce CPQ Implementation Guide09 Dec 2024 Blog
-
Overcoming Top 5 Common Sales Challenges With Salesforce Revenue Cloud06 Dec 2024 Blog
-
Empowering Sales Teams with Einstein: 5 Proven Methods to Drive Sales Success05 Dec 2024 Blog
-
Mirketa Recognized by NetSuite as Summer 2024 Alliance Partner Spotlight Award Winner04 Dec 2024 Blog
-
Salesforce Agentforce: Revolutionizing AI with Autonomous Agents03 Dec 2024 Blog
-
How to send information from one Salesforce Org A to another Org B using Salesforce Integration?30 Nov 2024 Blog
-
Mastering the Salesforce Quote to Cash Process: A Complete Guide for Businesses - Copy28 Nov 2024 E-Book
-
Salesforce Education Cloud in Higher Education: Transforming University Operations and Student Experience14 Nov 2024 Blog
-
The Future of Healthcare: Transforming with Salesforce Health Cloud & Elixir EHR14 Nov 2024 Blog
-
Mastering the Salesforce Quote to Cash Process: A Complete Guide for Businesses13 Nov 2024 Webinar
-
Mastering the Salesforce Quote to Cash Process: A Complete Guide for Businesses30 Oct 2024 E-Book
-
Mastering the Salesforce Quote to Cash Process: A Complete Guide for Businesses28 Oct 2024 Blog
-
Integrating Amazon OpenSearch Service with Salesforce26 Oct 2024 Blog
-
Salesforce Support and Services: Why They Are a Must for Optimizing CRM Performance10 Oct 2024 Blog
-
Salesforce Admin Support: Unveiling the Backbone of CRM Success03 Oct 2024 Blog
-
Mastering Salesforce Financial Services Cloud: A Step-by-Step Implementation Guide03 Oct 2024 Blog
-
Recap Dreamforce 2024: Unleashing the Power of AI and Data with Mirketa27 Sep 2024 Blog
-
How Salesforce’s Agentforce Revolutionizes Manufacturing Operations26 Sep 2024 Blog
-
Top 5 Benefits and Use Cases of Implementing Salesforce Health Cloud for Healthcare Providers24 Sep 2024 Blog
-
A Beginner’s Guide to NPSP Basics13 Sep 2024 Blog
-
How to Avoid 9 Common Mistakes when Selecting a Salesforce Consulting Partner09 Sep 2024 Blog