Installation
Prerequisites
- An environment with Python 3.10 or later installed.
- Blocks account and API key.
- Blocks Github App.
If you’d like to use Blocks with other providers such as Gitlab or Bitbucket, please reach out: dev@blocksorg.com.
Install Blocks
Initialize Blocks
We’ll verify your API key and create a .blocks
directory in the current working directory.
Create an automation
The easiest way to create an automation is to use the create
command.
This will create a new automation in the .blocks
directory with the following structure:
Below are two example automations you can copy to get started. The first one is a simple hello world, and the second one is a more complex automation that leverages the litellm
library to summarize a pull request in a single sentence.
For the second automation, we’ve added the litellm
library as a dependency to requirements.txt
. To use gpt-4o
, litellm
expects an environment variable called OPENAI_API_KEY
. You would need to get your own OpenAI API key and add it to the environment variables dashboard.
Register an automation
Automations are registered with the push
command; specify the filename relative to your current working directory. All automations defined the file will be registered, however you can only register one file at a time.
Install Github App
Ensure you have the Blocks Github App installed on your repository so Blocks can trigger your automation.
Project Structure
The .blocks
directory is where automation source code is defined. A typical project structure looks like the following:
Dependencies are isolated to each automation, and there are no restrictions for supported pip
packages.
Version Control
Ideally, your automations will be checked into some git provider for version control and storage, just like any other source code. We do preserve the state of registered automations, but do not implement git for version control. However, this is something we can add if requested.
Where do I get an API key?
API keys are created and managed in the dashboard.