CICD Build & Deployment in SAP Commerce CCV2 from GitHub Actions

Aswin Raghuraman
SAP Commerce Cloud
Published in
5 min readJul 1, 2022

SAP Commerce Cloud is a highly customizable, extension/module based, flexible & scalable eCommerce Platform which is used by lot of high-end customers like Samsung, etc. It can be either hosted in our own cloud/on-premises environment or on the SAP supported cloud environment. The SAP supported PaaS provides all the infrastructure required to host the eCommerce Platform and run the eCommerce website.

The previously released CCV1 is based on SAP Cloud and it had lot of limitations. Later, SAP moved on to public cloud infrastructure ( Microsoft Azure Cloud) to host the SAP Commerce cloud. And its called CCV2. The customer can integrate their git repo and manually build & deploy the code from the SAP Commerce portal to host their website without any downtime of storefront/OCC APIs, which is a BIG win.

To automate the whole process, SAP has recently released Commerce Cloud APIs to build, deploy and track the progress. In this tutorial, we will create a executable GitHub action pipeline using APIs. Lets get started!

GitHub Action Pipeline

The below four stages are created in the pipeline to accomplish the task.

Follow the steps to create the pipeline

  1. Navigate to GitHub Workflow

Navigate to the Github Code repository -> Actions ->click New Workflow Button

It should show the below page.

Here Click set up a workflow yourself link

2. Create CCV2 Build/Deployment workflow

After the step1, it will show the below file editor.

GitHub uses the YAML notation for the workflow definition. Read more on GitHub actions here

Delete the contents of this file and replace with the below content. Source code here

Save the file to your repo. It will get saved in your code repo [ .github/workflows/ ] and its ready for execution.

Understanding the pipeline

Pipeline Trigger

The pipeline is triggered using the below shown configuration

In this specific pipeline, the pipeline will get triggered when a push happens to these branches. For testing purposes, only the Dev and Staging envs are configured in this pipeline. Once its mature, you can go ahead and configure it to deploy in Prod env as well. I’ll leave it to you.

workflow_dispatch: Adding this command will enable the option of manual trigger of pipeline.

Navigate to the actions tab. Once you add this command, you should get the Run workflow . Click it to select the branches to deploy.

Configuration of Environment variables

There are two kinds of variables configured in the pipeline

  1. Hardcoded environment variables
  2. Secret keys from the repo. [ They are stored as GitHub secrets and while execution it will fetch the details ]

How to configure the secret keys in GitHub

Navigate to the Code repo -> Settings -> Click Secrets -> Actions ( as shown below)

Click the New Repository Secret button and add the following secret env keys/values

  • CCV2_AUTH_ACCESS_TOKEN — Create the API Access Token from your SAP Account here
  • CCV2_SUBSCRIPTION_CODE — Add your SAP Commerce subscription code here

Pipeline steps

  1. Create Build — The CCV2 API to create the build will be invoked and get the build code generated in SAP Commerce cloud
  2. Create Build Progress — The CCV2 API to get the build details will be invoked every 10 mins to check the build status. After completion of the build, if the build is success it will proceed to the next deployment step.
  3. Create Deployment — The CCV2 API to create deployment will be invoked with the build and environment details. It will get the deployment code in response.
  4. Create Deployment Progress — The CCV2 API to get the deployment details will be invoked every 10 mins to check the deployment status. After completion of the deployment, the workflow will get completed.

An email notification will be sent to the configured email addresses as below.

Execution

The pipeline will get triggered when code is pushed to develop or release/* branches. [ In typical scenario, it happens after the PR is approved and merged]

Click the actions tab, to view the list of workflows and the recent one which is in progress.

Click of the workflow to get more details of the job. The steps can be expanded further to get more details of the job steps.

After the last step, the workflow will be marked as complete. Login and verify in the SAP Commerce Cloud portal. You should be able to see the same build and deployment of specified env.

Conclusion

The provided step by step process and code in the tutorial will enable you to run the pipeline in minutes. Hope you enjoyed reading this post.

Kindly give a like or clap on my post if you have learned something new and follow me to get more posts on SAP Commerce.

--

--

Aswin Raghuraman
SAP Commerce Cloud

eCommerce expert, Solution Architect and Developer. Knowledge on multiple platforms SAP commerce Cloud, BigCommerce, AEM, Celum and Azure Cloud DevOps