Skip to main content

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, update the desired code in the code.txt file.
  3. Deploy the code using the E2E CLI. Refer to the 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 an API key and Auth Token from the 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:
    • First, 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 the 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. It is important to ensure that you keep the repository name as the name of the Function. When you clone this to your local machine, a directory with the Function name will be created.

  2. The local directory must have a file named 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 the MyAccount cloud console for the entry-level Function name.
  3. The local directory must also contain a file named environment.txt. This file 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.

    Environment Variables Format

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

    • Required package file: The file name will be runtime-specific. The user will define this file name according to the language they are writing code in. Currently, the following runtimes and their corresponding requirement/package file names are listed:
      • Node: package.json
      • Python: requirements.txt
      • C#: Function.csproj
      • Ruby: Gemfile
  5. Deploy the code using the E2E CLI. Refer to the 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. For a detailed example, please refer to the Documentation.