GitHub CI/CD Discovery

Set up microservices discovery in your GitHub CI/CD pipelines.

🚧

Early Adopter Release

This feature is currently in early adopter release and may not be available to all users.

Overview

If your organization uses GitHub as a platform for hosting code repositories, you can establish an automated process for microservices discovery by configuring GitHub CI/CD pipelines. Automated discovery ensures consistent updates and accurate representation of microservices within your system.

Prerequisites

Before you start, prepare the following:

  • A YAML manifest file
  • A relevant Python script

To learn how to create a YAML file and a Python script, see Microservice Discovery Through a Manifest File.

Configuring Your GitHub Workflow

The GitHub pipeline outlined in this guide is designed to automatically update your microservices on each push or pull request to the main branch. This ensures your microservice fact sheets are consistently updated with the latest changes. The workflow includes the following steps:

  1. Checking out your code
  2. Setting up Python
  3. Installing the necessary Python dependencies
  4. Invoking the SAP LeanIX service discovery Python helper

To set up this workflow, create a new GitHub workflow in your repository under .github/workflows. For instructions, refer to the GitHub documentation.

The following YAML script outlines the workflow:

name: Microservice Workflow
on:
  pull_request:
    types:
      - closed
    branches: [main]
env:
  LEANIX_API_TOKEN: ${{ secrets.LEANIX_API_TOKEN }}
  LEANIX_SUBDOMAIN: ${{ vars.LEANIX_SUBDOMAIN }}

jobs:
  update_microservice:
    runs-on: ubuntu-latest
    env:
      REPOSITORY_URL: ${{ github.repositoryUrl }}
    steps:
      - name: Checkout code
        uses: actions/checkout@v2
      - name: Set up Python
        uses: actions/setup-python@v2
        with:
          python-version: "3.12"
      - name: Install Python dependencies
        run: |
          python -m pip install --upgrade pip
          pip install requests pyyaml
      - name: Invoke Manifest Parser
        run: python leanix_service_discovery.py

By automating these steps, you not only streamline your microservice discovery process but also ensure accuracy and consistency in your microservice fact sheets.