CI/CD#

Malevich has its own Github Actions Workflow pipeline for building and delivering apps to Space.

Requirements#

In order to automatically build your apps and upload them to Space:

  1. App folders should be inside the root directory.

  2. Each app should contain Dockerfile and space.yaml files.

For example:

your_repository/
├─ app1/
   ├─ apps/
   ├─ Dockerfile
   ├─ space.yaml
├─ app2/
   ├─ apps/
   ├─ Dockerfile
   ├─ space.yaml
...
  1. You will need the following credentials:
    • Space credentials: Username, Token/Password and Organization slug (optional).

    • Github PAT.

    • Docker registry info: Registry Host URL, Repository ID/Name, Credentials (username and password).

      Full list:

└─$ malevich ci github init --help

Usage: malevich ci github init [OPTIONS]

Initialize the Github CI/CD pipeline

╭─ Options ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ --interactive     --no-interactive          Run the initialization wizard                                                                                                                                              │
│ --repo-name                           TEXT  Github repository name in the format <username>/<repo-name>                                                                                                                │
│ --github-token                        TEXT  Github token with access to the repository                                                                                                                                 │
│ --space-user                          TEXT  Malevich Space username                                                                                                                                                    │
│ --space-token                         TEXT  Malevich Space token (password)                                                                                                                                            │
│ --space-url                           TEXT  Malevich Space API URL                                                                                                                                                     │
│ --branch                              TEXT  Branch to setup CI in                                                                                                                                                      │
│ --registry-url                        TEXT  Docker Image Registry URL, for example `public.ecr.aws` or 'cr.yandex'                                                                                                     │
│ --registry-id                         TEXT  Docker Registry ID                                                                                                                                                         │
│ --image-user                          TEXT  Username to access the Docker Image Registry                                                                                                                               │
│ --image-token                         TEXT  Password to access the Docker Image Registry                                                                                                                               │
│ --org-id                              TEXT  Malevich space organization ID                                                                                                                                             │
│ --help                                      Show this message and exit.                                                                                                                                                │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

Run#

After all requirements were satisfied, use malevich ci github init command to start initialization.

└─$ malevich ci github init --interactive
Welcome to the Github CI/CD pipeline initialization wizard!
Enter the Github repository name in the format <username>/<repo-name>: MalevichAI/malevich-example
Enter the Github token with access to the repository (ghp_...): ghp_*******
Enter the username to access Malevich Space (leave empty to use access token instead): user@example.com
Enter the password to access Malevich Space: ***
Enter the host of Malevich Space  (https://dev.api.malevich.ai): https://dev.api.malevich.ai
Enter the branch to run the pipeline on (main): main
Enter the Docker Container Registry type [other/ecr/ecr-private/yandex/ghcr]: ghcr
Enter the Docker Container Registry URL: ghcr.io
Enter the Docker Container Registry ID: repo_id
Enter the username to access the Docker Container Registry: username
Enter the password to access the Docker Container Registry: ****

This command will pass all arguments to your github repository secrets and create 2 files inside .github/workflows directory:

  1. malevich_ci__<branch>.yml: Auto CI, which will build and push all apps that were changed in the commit which triggered the workflow.

  2. malevich_ci__manual.yml: CI, which can be triggered manually. It will build all the apps in the repository.

References#