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
- Set up the Function using the E2E CLI. Refer to the Documentation for guidance.
- After setting up the Function using E2E CLI, update the desired code in the
code.txt
file. - Deploy the code using the E2E CLI. Refer to the Documentation.
- Initialize Git in the Function folder.
- Create a repository with the same name as the Function folder on GitHub.
- Push the code to this repository.
- Generate an API key and Auth Token from the MyAccount cloud console. Refer to this Documentation.
- 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
andE2E_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 namedworkflows
. - Inside the
workflows
folder, create a file nameddeploy.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.
-
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.
-
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.
-
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.
-
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
- Node:
- 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:
-
Deploy the code using the E2E CLI. Refer to the Documentation.
-
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.
-
For a detailed example, please refer to the Documentation.