diff --git a/.github/workflows/build_prod_template.yml b/.github/workflows/build_prod_template.yml new file mode 100644 index 00000000..3472f462 --- /dev/null +++ b/.github/workflows/build_prod_template.yml @@ -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 }} diff --git a/.github/workflows/build_test_template.yml b/.github/workflows/build_test_template.yml index 3f39bc41..182426f9 100644 --- a/.github/workflows/build_test_template.yml +++ b/.github/workflows/build_test_template.yml @@ -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 @@ -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 @@ -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 }} diff --git a/template/build_ci.py b/template/build_ci.py index 1c89b472..13c0c311 100644 --- a/template/build_ci.py +++ b/template/build_ci.py @@ -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") diff --git a/template/build_prod.py b/template/build_prod.py index 5274d8c4..1615ebff 100644 --- a/template/build_prod.py +++ b/template/build_prod.py @@ -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" + Template.build( make_template(), alias="code-interpreter-v1", cpu_count=2, memory_mb=2048, + skip_cache=skip_cache, on_build_logs=default_build_logger(), )