Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .github/workflows/build_prod_template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Build Prod Template

on:
workflow_dispatch:
inputs:
skip_cache:
description: Skip build cache
required: false
type: boolean
default: false

concurrency:
group: Release-${{ github.ref }}
cancel-in-progress: false

permissions:
contents: read

jobs:
build-template:
name: Build E2B template
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- uses: actions/setup-python@v6
with:
python-version: '3.13'

- name: Install development dependencies
working-directory: ./template
run: pip install -r requirements-dev.txt

- name: Build E2B template
id: build-template
working-directory: ./template
run: |
python build_prod.py
env:
E2B_API_KEY: ${{ secrets.E2B_PROD_API_KEY }}
E2B_DOMAIN: ${{ vars.E2B_DOMAIN }}
SKIP_CACHE: ${{ inputs.skip_cache }}
10 changes: 5 additions & 5 deletions .github/workflows/build_test_template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
name: Build E2B Template
runs-on: ubuntu-latest
outputs:
template_id: ${{ steps.generate-template-id.outputs.template_id }}
template_id: ${{ steps.build-template.outputs.template_id }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand All @@ -42,12 +42,12 @@ jobs:
working-directory: ./template
run: pip install -r requirements-dev.txt

- name: Generate Template ID
- name: Generate Template Name
id: generate-template-id
run: |
E2B_TESTS_TEMPLATE=e2b-code-interpreter-ci-$(uuidgen)
echo "Generated Template ID: $E2B_TESTS_TEMPLATE"
echo "template_id=$E2B_TESTS_TEMPLATE" >> $GITHUB_OUTPUT
echo "Generated Template Name: $E2B_TESTS_TEMPLATE"
echo "template_name=$E2B_TESTS_TEMPLATE" >> $GITHUB_OUTPUT

- name: Build E2B template
id: build-template
Expand All @@ -57,4 +57,4 @@ jobs:
env:
E2B_API_KEY: ${{ secrets.E2B_API_KEY }}
E2B_DOMAIN: ${{ inputs.E2B_DOMAIN }}
E2B_TESTS_TEMPLATE: ${{ steps.generate-template-id.outputs.template_id }}
E2B_TESTS_TEMPLATE: ${{ steps.generate-template-id.outputs.template_name }}
10 changes: 9 additions & 1 deletion template/build_ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,18 @@
from e2b import Template, default_build_logger
from template import make_template

Template.build(
build_info = Template.build(
make_template(),
alias=os.environ["E2B_TESTS_TEMPLATE"],
cpu_count=2,
memory_mb=2048,
on_build_logs=default_build_logger(),
)

template_id = build_info.template_id
print(f"Built template ID: {template_id}")

github_output = os.getenv("GITHUB_OUTPUT")
if github_output:
with open(github_output, "a", encoding="utf-8") as fh:
fh.write(f"template_id={template_id}\n")
5 changes: 5 additions & 0 deletions template/build_prod.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import os

from dotenv import load_dotenv
from e2b import Template, default_build_logger
from template import make_template

load_dotenv()

skip_cache = os.getenv("SKIP_CACHE", "false").lower() == "true"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you just convert this to bool?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

preferring to check the value is actually true vs exists; otherwise it'll be any string, although I see the flip side that it's only set right now to "true". can change if really want it though.


Template.build(
make_template(),
alias="code-interpreter-v1",
cpu_count=2,
memory_mb=2048,
skip_cache=skip_cache,
on_build_logs=default_build_logger(),
)