How to Build the Commit Page for the Commit Action in Multi-Cloud
The Commit action is a method of the Copado Multi-Cloud platform API that is used to perform the commit process.
The commit is a process used in Copado to link changes to a user story, record them in a Git repository and then deploy those committed changes to the different environments in your pipeline. To do this, when you commit changes in a user story, Copado creates a feature branch with the changes and then merges that branch into the source environment branch.
At Copado we work tirelessly to avoid users, customers and partners having to spend time building their own solutions, but in some cases you may need to build your own commit action. For instance, in the following situations:
- We may not have or provide a standard Commit action for the platform, technology or cloud that you are working with.
- Our out-of-the-box Commit action does not comply with some of your requirements.
In this section we will provide you all the information that you need to build the commit page for the commit action.
Build the Commit Action for a Multi-Cloud Solution
As every action, the Commit action consists of three different parts:
- An invocable method
- A job template
- A callback
Both the invocable method and the callback are automatically executed by Copado, but you will need to perform the following steps for your Commit action to be executed in your Multi-Cloud extension:
- Create a job template.
- Create a Lightning Web Component that retrieves files or changes from your source system or environment and populates the commit Table, and configure the component in the flexipage. This component is what we call “Table Actions”.
- Integrate the “Table Actions” Component with the Commit Table.
Creation of the Job Template
This job template is a reusable template with a list of steps that will be executed as part of the commit process to execute low level operations such as:
- Decide if you need to create or reuse a feature branch.
- Retrieve the files changes from the source and commit them.
- Push the feature branch changes into the version control.
Creation of the “Table Actions” Lightning Web Component
In order to populate the Commit Table with information about the file changes that have been made, you will need a component that helps users interact with your source system or environment, describe or retrieve these changes and display them in the Table, so they can manage this information more easily.
We refer to this component as “Table Actions”, as it provides actions (such as buttons) that help the user retrieve changes. The implementation of this component is entirely up to what you consider your users need and what is the best way to interact with the source system. In our own components, we like to give users the possibility to specify a date, time and the component type, for example, so that they have more options to filter their changes and be more assertive with their search.
Additionally, you can use the power of Copado Functions within your component to develop the complex logic and operations required to obtain the data from external systems (API connections, processing, parsing, etc.).
Integrating the “Table Actions” Component with the Commit Table
To enable this level of flexibility so that you can leverage your own components and build extensions, the User Story Commit page is designed to dynamically render UI (LWC) components through the configuration of custom metadata types, which can be packaged as part of an extension package (such as unlocked packages) so that end users can use the commit capabilities of your extension without any manual requirements.
The User Story Commit page for Multi-Cloud contains 4 main components:
- The Header, which is a standard component provided by Copado.
- The Table Action, which depends on the extension.
- The Table, which is a standard component provided by Copado.
- Git Operations, which is a standard component provided by Copado.
For the Table to be populated with the file changes, you will need to configure the Table Action component so that it communicates with the Table component. This communication happens via Lightning Message Service (LMS).