Manage E2E Functions using GitActions

Introduction

This document describes the steps and procedures to manage E2E Functions using GitActions.

Users can conveniently manage their Functions through the GitHub repository, eliminating the need to redeploy via the UI for every change. By simply pushing changes to GitHub, the Functions are automatically synchronized and deployed on e2e Functions.

Prerequisite

Users should possess a basic understanding of the E2E CLI to utilize the concept of GitOps to manage their Functions. For further clarification, please refer to the documentation - Functions using e2e cli

Setup GitOps (via GitActions) for new Functions on the E2E Cloud

  1. Set up the Function using the e2e-cli. Refer to the Documentation for guidance.

  2. After setting up the Function using e2e-cli user can update the desired Code in the code.txt file.

  3. Deploy the code using the e2e-cli. Documentation

  4. Initialize Git in the Function folder.

  5. Create a repository with the same name as the Function folder on GitHub.

  6. Push the code to this repository.

  7. Generate API key and Auth Token from Myaccount cloud console. Refer to this Documentation

  8. Set up a workflow to automatically redeploy the code on e2e Functions whenever it is updated and pushed to the GitHub repository.
    • To set up the workflow, first, you need to set up secrets in your GitHub repository. Refer to this Documentation for instructions.

    • Create two secrets named E2E_API_KEY and E2E_AUTH_TOKEN and put their value as API key and Auth Token respectively.

      Note

      Use the same names while creating secrets.

    • Create a folder named .github in the current repository where you initialized Git.

    • Inside the .github folder, create another folder named “workflows”.

    • Inside the workflows folder, create a file named deploy.yml, which will connect the GitHub repository with e2e Functions.

    • This is the template that you can use to connect. Feel free to change it according to your use case. sample template

Migration of Functions from other cloud platforms to E2E Functions

A pre-defined convention must be followed to make the function directory structure compatible with E2E Functions.

  1. The Function will be created by the name of the GitHub repository. So this is important to understand that you keep the repository name as the name of the Function. When you clone this to your local, a directory with the Function name will get cloned.

  2. The local directory must have a file - code.txt

    • code.txt => This file will contain your Function code. The entry-level Function name is runtime-specific. For example, for Python it is “handle”. Kindly check the E2E Function on MyAccount cloud console for referring to the name of the entry-level Function.

  3. The local directory also must contain a file - environment.txt. It can be kept empty if required.

    • environment_variable.txt => This file contains your environment variables and must be in the key-pair value format. Please refer to the following screenshot to see the format you need to keep to define the environment variables.

    ../_images/gitops1.png
  4. The repository or the local directory also must contain another file to keep the code dependency/library information. It can be kept empty if required.

    • Required package file like “requirements.txt” => This file name will be runtime-specific. The user will define this file name according to the language they are writing code in. At present we provide the following runtime and their corresponding requirement/package file names are listed as follows:

      • Node: package.json

      • PYTHON: requirements.txt

      • CSHARP: Function.csproj

      • RUBY: Gemfile

  5. Deploy the code using the e2e CLI. Documentation

  6. After these changes, you can continue with step 7 of “Setup GitOps (via GitActions) for new Functions on the E2E Cloud” to set up the GitActions workflow.

  7. Detailed example. Please refer to the Documentation