Skip to content

Commit c454262

Browse files
add workflow dispatch to deploy the template (#211)
* build prod template has a workflow dispatch
1 parent ef62fb8 commit c454262

File tree

4 files changed

+61
-6
lines changed

4 files changed

+61
-6
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Build Prod Template
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
skip_cache:
7+
description: Skip build cache
8+
required: false
9+
type: boolean
10+
default: false
11+
12+
concurrency:
13+
group: Release-${{ github.ref }}
14+
cancel-in-progress: false
15+
16+
permissions:
17+
contents: read
18+
19+
jobs:
20+
build-template:
21+
name: Build E2B template
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Checkout repository
25+
uses: actions/checkout@v4
26+
- uses: actions/setup-python@v6
27+
with:
28+
python-version: '3.13'
29+
30+
- name: Install development dependencies
31+
working-directory: ./template
32+
run: pip install -r requirements-dev.txt
33+
34+
- name: Build E2B template
35+
id: build-template
36+
working-directory: ./template
37+
run: |
38+
python build_prod.py
39+
env:
40+
E2B_API_KEY: ${{ secrets.E2B_PROD_API_KEY }}
41+
E2B_DOMAIN: ${{ vars.E2B_DOMAIN }}
42+
SKIP_CACHE: ${{ inputs.skip_cache }}

.github/workflows/build_test_template.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
name: Build E2B Template
2323
runs-on: ubuntu-latest
2424
outputs:
25-
template_id: ${{ steps.generate-template-id.outputs.template_id }}
25+
template_id: ${{ steps.build-template.outputs.template_id }}
2626
steps:
2727
- name: Checkout repository
2828
uses: actions/checkout@v4
@@ -42,12 +42,12 @@ jobs:
4242
working-directory: ./template
4343
run: pip install -r requirements-dev.txt
4444

45-
- name: Generate Template ID
45+
- name: Generate Template Name
4646
id: generate-template-id
4747
run: |
4848
E2B_TESTS_TEMPLATE=e2b-code-interpreter-ci-$(uuidgen)
49-
echo "Generated Template ID: $E2B_TESTS_TEMPLATE"
50-
echo "template_id=$E2B_TESTS_TEMPLATE" >> $GITHUB_OUTPUT
49+
echo "Generated Template Name: $E2B_TESTS_TEMPLATE"
50+
echo "template_name=$E2B_TESTS_TEMPLATE" >> $GITHUB_OUTPUT
5151
5252
- name: Build E2B template
5353
id: build-template
@@ -57,4 +57,4 @@ jobs:
5757
env:
5858
E2B_API_KEY: ${{ secrets.E2B_API_KEY }}
5959
E2B_DOMAIN: ${{ inputs.E2B_DOMAIN }}
60-
E2B_TESTS_TEMPLATE: ${{ steps.generate-template-id.outputs.template_id }}
60+
E2B_TESTS_TEMPLATE: ${{ steps.generate-template-id.outputs.template_name }}

template/build_ci.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,18 @@
22
from e2b import Template, default_build_logger
33
from template import make_template
44

5-
Template.build(
5+
build_info = Template.build(
66
make_template(),
77
alias=os.environ["E2B_TESTS_TEMPLATE"],
88
cpu_count=2,
99
memory_mb=2048,
1010
on_build_logs=default_build_logger(),
1111
)
12+
13+
template_id = build_info.template_id
14+
print(f"Built template ID: {template_id}")
15+
16+
github_output = os.getenv("GITHUB_OUTPUT")
17+
if github_output:
18+
with open(github_output, "a", encoding="utf-8") as fh:
19+
fh.write(f"template_id={template_id}\n")

template/build_prod.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
1+
import os
2+
13
from dotenv import load_dotenv
24
from e2b import Template, default_build_logger
35
from template import make_template
46

57
load_dotenv()
68

9+
skip_cache = os.getenv("SKIP_CACHE", "false").lower() == "true"
10+
711
Template.build(
812
make_template(),
913
alias="code-interpreter-v1",
1014
cpu_count=2,
1115
memory_mb=2048,
16+
skip_cache=skip_cache,
1217
on_build_logs=default_build_logger(),
1318
)

0 commit comments

Comments
 (0)