GitHub Integration (via Microsoft Power Automate)

Last modified on 2022/11/04 18:18

IntegrationIntroduction

You can integrate third-party systems with Service Manager in many ways. The method you select will depend on business requirements, architectural and security constraints as well as the characteristics specific to each third-party application or service.

This document describes an integration process that has already been implemented in a customer context. 

To find out more about this integration (e.g. scripts to be used), please do not hesitate to contact your EasyVista contact, or your service provider and integrator.

Overview of the integration

GitHub is an online service that hosts websites and source code files, and provides distributed version control using Git. It is also a collaborative space where each user can contribute content to online public projects.

This integration enables you to create an issue in GitHub when a Service Manager>>doc:Request For Change]] change request is associated with a [[release project, via Microsoft Power Automate. The change request is then automatically closed when the issue is closed in GitHub.
 

Preview of the tools used in this integration

IntegrationTool_MicrosoftPowerAutomate
  • Microsoft Power Automate (formerly known as Microsoft Flow): It enables you to automate recurrent tasks by building workflows using Web applications. The tool relies on standard connectors based on Microsoft Azure Logic Apps for interfacing with any endpoint via HTTP/HTTPS. It can also use the Microsoft Graph gateway via the Microsoft Graph API.

 

Integration Data Feed (direction) Authentication Type Integration Connector Options

Logo - EV Service Manager.png

Down arrow.png

Logo Icon - Microsoft Flow.png

Down arrow.png

Logo Icon - GitHub.png

Down arrow.png

Logo Icon - Microsoft Flow.png

Down arrow.png

Logo - EV Service Manager.png

  • Depending on the third-party service used (authentication managed by Logic Apps)
  • Basic Authentication for the Service Manager REST API
  • Service Manager:

    EV Integration connector icon - Workflow.png    Workflows

    EV Integration connector icon - Business rule.png    Business rules

  • MS Power Automate:

    EV Integration connector icon - Receive.png    Connector: When a HTTP request is received

    (Service Manager trigger => Logic Apps)

Available versions
SaaS-based On-premises
Service Manager Check icon.png Check icon.png
Third-Party Product Check icon.png N/A

GitHub - definitions

Definitions_GitHub
  • GitHub is an online service that hosts websites and source code files, and provides distributed version control using Git. It is also a collaborative space where each user can contribute content to online public projects.
  • Git is a distributed version control system for tracking project changes and saving them in different versions, thus enabling you to revert back to an older version at any time.
  • In Git, the copy of all project files and versions is called a repository. This is a storage space on the centralized GitHub server that contains each source code.
  • Issues are created to initiate discussions among developers, bug reports, proposed developments, etc.
  • A pull request is a procedure that enables an external contributor to propose changes to the original code (request), integrate feedback and resubmit them (pull).
  • A review is used to evaluate, comment and validate the changed code in the pull request. Once code changes are approved by the review, the pull request is merged with the original version.

Microsoft Power Automate flows

The integration between Service Manager and GitHub will trigger two flows in Microsoft Power Automate when a change request is associated with a release project in Service Manager.

MS Power Automate Flow 1: Create an issue in GitHub MS Power Automate Flow 2: Close the Service Manager request
Data feed diagram 1 - EN.png Data feed diagram 2 - EN.png

Prerequisites

  • You must have an account authorizing access to the Service Manager platform with a profile and access rights to create and modify workflows, access the Administration menu and other required menus, such as Service Operation and Service Transition.

Best Practice

BestPractice
  • The procedure describes all of the steps for creating Microsoft Power Automate flows. To facilitate integration, the ZIP folders shipped with this integration contain pre-configured flows. Once you have downloaded them, you should specify the parameters specific to your environment, i.e. Azure account credentials, EasyVista server address, credentials of your Service Manager platform, etc.
  • Use the search field to find the connectors and actions to be created in the MS Power Automate workflow easily.

    example  Find the actions for the Azure DevOps connector

    Microsoft Power Automate - Best Practice search connector.png

Caution

Caution_TitleActionInPowerAutomateFlow
  • When you create workflow actions in Microsoft Power Automate, you must rename them as indicated in the procedure. This is because certain items of information in the name refer to the title of the action. If you do not respect the naming convention, the workflow will not be triggered correctly.

example  The split(body('Analyze_Ticket_Info')'')?['AVAILABLE_FIELD_6'],',') instruction refers to the action called Analyze Ticket Info

Note: Spaces in the title will automatically be replaced by the underscore _.

Integration process

1. Create the MS Power Automate flows. Open url.png See the step-by-step integration process:

  • Note: This requires a connection to GitHub.

Best Practice icon.png  Import the preconfigured flows below containing all of the steps to MS Power Automate. Open url.png See the procedure for importing flows.
       Download icon.png  FlowCreate an issue in GitHub

        Download icon.png  FlowClose the Service Manager request

2. Go to Service Manager and create a resource called GitHub issue associated with a Microsoft Power Automate service. Open url.png See the detailed procedure.

You can then use the GitHub issue resource in a REST step in the ticket creation process.

Step-by-Step Integration Process

Import the workflow to Microsoft Power Automate

Note: This requires a connection to GitHub.

Step 1: Download the flow

1. Download the file below to your workstation.

        Download icon.png  FlowCreate an issue in GitHub

        Download icon.png  FlowClose the Service Manager request

ImportFlowInMicrosoftPowerAutomate_Procedure

Step 2: Import the flow to Microsoft Power Automate 

1. Log in to the Microsoft Power Automate website using your account credentials.

2. Click My flows in the left pane.

A list of your MS Power Automate flows will appear.
         Microsoft Power Automate - Import flow - Flow list.png

3. Click Import in the menu bar and select the file you downloaded.

  • Once imported, the package contents will appear.
  • The Red nok icon.png icon indicates that the connection for the resource was not found.
    Microsoft Power Automate - Import flow - Package content.png

 

Step 3: Create the connections required for the flow

1. Click the Select during import link in the Import Setup column for the relevant resource.

          Microsoft Power Automate - Import flow - Import setup link.png

The window for configuring the import will appear.
         Microsoft Power Automate - Import flow - Import setup window.png

2. Create a new connection for the resource or select an existing connection.

There is an existing connection for the resource

  • Select the connection.
  • Click Save.
    Microsoft Power Automate - Import flow - Import setup - Select existing connection.png

There is no existing connection for the resource

  • Click + Create.
    Microsoft Power Automate - Import flow - Import setup - Create connection.png
    • An MS Power Automate instance will appear in a new Web browser tab.
    • The list of existing connections will appear.
               Microsoft Power Automate - Import flow - Import setup - Create connection 2.png
  • Click + New connection.
  • Find the connection you want using the search field and select it from the list.

example  Find the GitHub connection

Microsoft Power Automate - Import flow - Import setup - Create connection 3.png

A window displaying the list of permissions to be granted to Microsoft Power Platform will appear.

  • Click Create to create the new connection.
  • Click Accept to accept the conditions and authorize Microsoft Power Platform access.
    • You will return to the tab displaying the list of MS Power Automate flows.
    • The new connection for the resource will appear in the list.

example  New GitHub connection

Microsoft Power Automate - Import flow - Import setup - New connection added.png

  • Close your Web browser tab.
    You will return to the tab displaying the details of the imported package.
  • Click Refresh List.
    The new connection for the resource will appear in the window for configuring the import.
             Microsoft Power Automate - Import flow - Import setup - Refresh list.png
  • Select the connection and click Save.
    The Black cross icon.png icon indicates that the connection for the resource has been correctly established.
             Microsoft Power Automate - Import flow - Import setup - New connection ok.png

3. Repeat the procedure for each connection required for the flow.
 

Step 4: Import package resources

1. Click Import.

          Microsoft Power Automate - Import flow - Button.png

The Green ok icon.png icon next to each package resource indicates that the flow has been correctly imported.
         Microsoft Power Automate - Import flow - Ok.png

Step 5: Configure package resources

Note: You should perform this step if a message at the top of the page informs you that package resources must be configured.

1. Click Save as new flow in the message displayed at the top of the page.

         Microsoft Power Automate - Import flow with error - Save as new flow.png

  • An MS Power Automate instance will appear in a new Web browser tab.
  • The workflow of the imported package will appear.
             Microsoft Power Automate - Import flow with error - Invalid connection.png

2. Click the action indicating an invalid connection.

The list of all existing connections for the selected type of resource will appear.
         Microsoft Power Automate - Import flow with error - Invalid connection - Select connection.png

2. Click the connection defined for the type of resource.

The properties of the action will appear. The properties displayed depend on the type of resource.

example  Unspecified properties for an action using the Azure DevOps resource

Microsoft Power Automate - Import flow with error - Invalid connection - Configure connection.png

3. Specify the connection information for the action.

example  Properties for an action using the Azure DevOps resource

  • Organization Name: Select the name of your organization.
  • Project Name: Select the name of your DevOps project.

4. Repeat the procedure for each action indicating an invalid connection.

5. Click Save.

  • The error message for the action will disappear.

example  Action for the Azure DevOps resource

Microsoft Power Automate - Import flow with error - Invalid connection - Configure connection ok.png

  • You have configured all of the connections required for the flow.
  • The workflow will be created.
             Microsoft Power Automate - Import flow - Success.png

 

Step 6:  Configure the workflow

1. Move your cursor over the name of the flow and click Edit icon.png.

          Microsoft Power Automate - Open flow.png

The workflow will appear.
         Microsoft Power Automate - Detail flow.png

2. See the procedure for configuring the imported flow.

Create MS Power Automate flow 1

Description of the Create an issue in GitHub workflow

Azure flow description - Creation GitHub issue.png
  • Step 1: Create the step that will trigger the flow
  • Step 2: Create an issue in GitHub
  • Step 3: Save the configuration of the workflow


Step 1: Create the step that will trigger the flow

==> The flow is triggered when a change request is associated with a release project in Service Manager.

1. Create a When a HTTP request is received step that will trigger the workflow.

Microsoft Power Automate - Trigger - When a http request is received.png
  • Specify the information on the trigger.
    • Body: Copy and paste the JSON schema below.

      Display the JSON schema

      {
         "$id": "http://example.com/example.json",
         "type": "object",
         "definitions": {},
         "$schema": "http://json-schema.org/draft-07/schema#",
         "properties": {
             "Description": {
                 "$id": "/properties/Description",
                 "type": "string",
                 "title": "Description",
                 "default": "",
                 "examples": [
                     "{Description}"
                  ]
              },
             "id": {
                 "$id": "/properties/id",
                 "type": "string",
                 "title": "Id",
                 "default": "",
                 "examples": [
                     "{id}"
                  ]
              },
             "Host": {
                 "$id": "/properties/Host",
                 "type": "string",
                 "title": "Host",
                 "default": "",
                 "examples": [
                     "{Host}"
                  ]
            
       },
             "URL": {
                 "$id": "/properties/URL",
                 "type": "string",
                 "title": "URL",
                 "default": "",
                 "examples": [
                     "{URL}"
                  ]
              },
             "Account": {
                 "$id": "/properties/Account",
                 "type": "string",
                 "title": "Account",
                 "default": "",
                 "examples": [
                     "{Account}"
                  ]
              }
          }
      }
    • Method: Select the POST value.
  • Save the trigger.

    The following information will be retrieved from Service Manager: Ticket description, ticket ID, Host, Account, URL, title of the ticket.

2. Click Copy icon.png to copy the URL displayed in the HTTP POST URL field and paste it in your text editor to store it temporarily. It will be required when defining the configuration in Service Manager (step 2).


Step 2: Create an issue in GitHub

1. Create a Html to text step to convert the description of the Service Manager request to plain text (Content Conversion connector).

Action Azure - Creation GitHub issue - Html to text.png
  • Specify the information on the action.
    • Contents: Select the dynamic value called Description from the When a HTTP request is received step that will trigger the flow.

2. Create a Create an issue action (GitHub connector).

Action Azure - Creation GitHub issue - Information.png
  • Specify the information on the action.
    • Repository Owner: Name of the owner of the GitHub folder.
    • Repository Name: Name of the GitHub folder where the GitHub issue should be created.
    • Title: ID of the Service Manager request. Select the dynamic value called ID from the When a HTTP request is received step that will trigger the flow.
    • Body: Description of the Service Manager request in plain text. Select the dynamic value called The plain text contain containing the result of the Html to text step.


Step 3: Save the configuration of the workflow

1. Click Save at the bottom of the flow.

          Azure flow 1 - Save configuration.png

Create MS Power Automate flow 2

Description of the Close the Service Manager request workflow

Azure flow description - GitHub issue closing.png
  • Step 1: Create the step that will trigger the flow
  • Step 2: Retrieve the closing comment for the GitHub issue
    • Step 2.a: Find information on the GitHub issue
    • Step 2.b: Store the closing comment of the GitHub issue in a Message variable
  • Step 3: Store the closing comment of the GitHub issue in the Service Manager request
  • Step 4: Close the Service Manager request
  • Step 5: Save the configuration of the workflow


Step 1: Create the step that will trigger the flow

==> The flow is triggered when the GitHub issue associated with the Service Manager change request is closed.

1. Create a When an issue assigned to me is closed step that will trigger the workflow (GitHub connector).

Action Azure - GitHub issue closing - When an issue assigned to me is closed.png

The step that will trigger the workflow is created. No parameter is required.


Step 2: Retrieve the closing comment for the GitHub issue


Step 2.a: Find information on the GitHub issue

1. Create a HTTP step to find the closing comment stored in the GitHub issue.

Action Azure - GitHub issue closing - HTTP action - Pulling comment.png
  • Rename it Pulling comment from GitHub using Browse black points icon.png in the title bar.
  • Specify the information on the action.
    • Method: Enter the GET value.
    • URI: Enter the following expression. Replace the values highlighted in yellow with the values of your GitHub account.
      concat(concat('https://api.github.com/repos/{your_repository_owner}/{your_repository_name}/issues/', triggerBody()?['number']),'/comments')
    • Headers:
      • Left column: Enter the Content-Type value.
      • Right column: Enter the application/json value.
      • Left column: Enter the Authorization value.
      • Right column: Enter the Bearer XXXXXXX value by replacing XXXXXXX with the GitHub token bearer.
    • Advanced options:
      • Authentication: Select the Basic value.
      • Username: Service Manager platform account.
      • Password: Password of the Service Manager platform account.


Step 2.b: Store the closing comment of the GitHub issue in a Message variable

1. Define the following variables by creating Initialize variable actions in the order listed below.

Microsoft Power Automate - Action - Initialize variable.png
Variable 1:
  • Specify the information on the action.
    • Name: Enter the Body value.
    • Type: Select the String value.
    • Value: Select the dynamic value called Body from the Pulling comment from GitHub step.
Variable 2:
  • Specify the information on the action.
    • Name: Enter the Body array value.
    • Type: Select the Array value.
    • Value: Enter the following expression.
      split(variables('Body'),';')

2. Define the following variable by creating a Compose action.

Microsoft Power Automate - Action - Compose.png
Compose 1:
  • Specify the information on the action.
    • Inputs: Enter the following expression.
      last(variables('Body array'))

3. Define the following variables by creating Initialize variable actions in the order listed below.

Microsoft Power Automate - Action - Initialize variable.png
Variable 1:
  • Rename the action initialize variable Message with split (comment) using Browse black points icon.png in the title bar.
  • Specify the information on the action.
    • Name: Enter the Message array value.
    • Type: Select the Array value.
    • Value: Enter the following expression.
      split(outputs('Compose'),'"')
Variable 2:
  • Rename the action initialize variable with Message using Browse black points icon.png in the title bar.
  • Specify the information on the action.
    • Name: Enter the Message value.
    • Type: Select the String value.
    • Value: Enter the following expression.
      variables('Message array')[3]


Step 3: Store the closing comment of the GitHub issue in the Service Manager request

1. Create an Update Request-Incident action (EasyVista Service Manager connector).

Action Azure - Update request - Information.png
  • Specify the information on the action.
    • Account: Specify your Service Manager account
    • Unique identification of request or incident: ID of the Service Manager request. Select the dynamic value called Title from the When an issue assigned to me is closed step that will trigger the flow.
    • Comment: Closing comment for the GitHub issue. Select the dynamic value called Message from the result of the Initialize variable > Message step.


Step 4: Close the Service Manager request

1. Create a Close Request-Incident action (EasyVista Service Manager connector).

Action Azure - Close request - Information.png
  • Specify the information on the action.
    • Account: Specify your Service Manager account
    • Unique identification of request or incident: ID of the Service Manager request. Select the dynamic value called Title from the When an issue assigned to me is closed step that will trigger the flow.
    • Closed comment: Closing comment for the GitHub issue. Select the dynamic value called Title from the When an issue assigned to me is closed step that will trigger the flow. Select the dynamic value called Message from the result of the Initialize variable > Message step.


Step 5: Save the configuration of the workflow

1. Click Save at the bottom of the flow.

          Azure flow 2 - Save configuration.png

Service Manager: Create a resource called GitHub Issue used in a REST step of a process

Notes:

  • The GitHub Issue resource will enable direct access to GitHub issues from Service Manager.
  • It is associated with a Microsoft Power Automate service.
  • It is used in a Service Manager process using a REST action type.
CreateInServiceManagerRestResource_Procedure

Step 1: Manage rights for using the Service Manager REST API

1. Select Administration > Access Management > User Profiles in the menu.

2. Select a user profile authorized to use the Service Manager REST API.

3. Tick the REST API box.

Your changes will automatically be saved.

4. Repeat the procedure for all authorized profiles.

Step 2: Create a resource called GitHub Issue associated with a Microsoft Power Automate service

        Open url.png See the detailed procedure.

Step 2.a: Create a service called Microsoft Power Automate

1. Select Administration > REST > Services in the menu.

2. Create a new service.

          New REST service - None authentication.png

3. Specify the information below.

  • Service Name: Enter the label Microsoft Power Automate.
  • Authentication Method: None.
  • Service URL: URL for accessing the new Microsoft Power Automate service.
    • Copy and paste the URL you stored in your text editor when creating the MS Power Automate flow (step that will trigger the flow).
    • You should keep only the text displayed in yellow below.

      https://prod-55.westeurope.logic.azure.com:443/workflows/a903f9140a874277be8b9dd39b5c4305/triggers/manual/paths/invoke?api-version=2016-06-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=R-FJw5q_MEn-I-98MNF794bVtN91QIWFt8gixg-8

    • Replace prod-55.westeurope with {subdomain}.
       

Step 2.b: Create a connection to the Microsoft Power Automate service.

1. Create a new connection.

          New REST connection - None authentication.png

2. Specify the information below.

  • Connection Name: Enter the label GitHub.
  • Authentication Method: None.
  • Service Name: Select the Microsoft Power Automate service you created at step 2.a.
    The URL of the service will automatically appear.
  • subdomain: Copy and paste the prod-55.westeurope value of the URL you stored in your text editor.
     

Step 2.c: Create a resource associated with the Microsoft Power Automate service

1. Create a new resource.

          New REST resource - None authentication.png

2. Specify the information below.

  • Label: Enter the label GitHub Issue.
  • Resource URI: ID of the new resource.
    • Copy and paste the URL you stored in your text editor when creating the MS Power Automate flow (step that will trigger the flow).
    • You should keep only the text displayed in yellow below.

      https://prod-55.westeurope.logic.azure.com:443/workflows/a903f9140a874277be8b9dd39b5c4305/triggers/manual/paths/invoke?api-version=2016-06-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=R-FJw5q_MEn-I-98MNF794bVtN91QIWFt8gixg-8

  • Contents: Body of the query containing the data to be updated. Copy and paste the text below without inserting any spaces or line breaks.

Caution: If you paste a JSON schema copied from a third-party editor such as Microsoft Word or Notepad++, invisible characters may be inserted. This will create an error in the processing of the REST step using the resource.

{"Description": "{Description}","id": "{id}","Host": "{sys.EVSM_HOST}","URL": "{sys.EVSM_REST_SERVICE_URL}","Account": "{sys.EVSM_ACCOUNT}"}

Step 3: Use the GitHub Issue resource in a REST step of a process

1. Open the workflow or the business rule-related process you want.

  • Workflow: References > Other References > Workflows (Operation/Transition)
  • Business rule: Administration > Business Rules > Related Processes

2. Click and drag the new GitHub Issue resource from the REST Actions category of the palette of action types to the graphic editor of the process.

A new step will be added to the process.

          New REST action in workflow - Add in GUI.png

3. Double-click to define the properties of the new step.

          New REST action in workflow - Properties.png

4. Click Confirm Changes.

Links to other integrations

Tags:
Powered by XWiki © EasyVista 2022