dynamic template id for each build #1
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build Template | ||
on: | ||
workflow_call: | ||
secrets: | ||
E2B_API_KEY: | ||
required: true | ||
E2B_ACCESS_TOKEN: | ||
required: true | ||
DOCKERHUB_USERNAME: | ||
required: true | ||
inputs: | ||
E2B_DOMAIN: | ||
required: false | ||
type: string | ||
E2B_TEMPLATE_CONFIG: | ||
required: true | ||
type: string | ||
permissions: | ||
contents: read | ||
jobs: | ||
build: | ||
name: Build Docker Image and Template | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- name: Set package version | ||
working-directory: ./template | ||
run: | | ||
VERSION=$(cat ../chart_data_extractor/pyproject.toml | grep version | cut -d '"' -f 2) | ||
echo "Version: $VERSION" | ||
sed -i "s/e2b_charts/e2b_charts==${VERSION}/g" requirements.txt | ||
- name: Build Docker image | ||
uses: docker/build-push-action@v6 | ||
with: | ||
context: ./template | ||
push: false | ||
platforms: linux/amd64 | ||
tags: ${{ secrets.DOCKERHUB_USERNAME }}/code-interpreter:latest | ||
- name: Install E2B CLI | ||
run: npm install -g @e2b/cli | ||
- name: Build E2B template | ||
id: build-template | ||
run: | | ||
OUTPUT=$(e2b template build --team "460355b3-4f64-48f9-9a16-4442817f79f5" --memory-mb 1024 -c "/root/.jupyter/start-up.sh" -d "e2b.Dockerfile") | ||
echo "build_output=$OUTPUT" >> $GITHUB_OUTPUT | ||
TEMPLATE_ID=$(echo "$OUTPUT" | grep -o '✅ Building sandbox template [a-z0-9]*' | cut -d' ' -f5) | ||
echo "template_id=$TEMPLATE_ID" >> $GITHUB_OUTPUT | ||
working-directory: ./template | ||
env: | ||
E2B_ACCESS_TOKEN: ${{ secrets.E2B_ACCESS_TOKEN }} | ||
E2B_DOMAIN: ${{ inputs.E2B_DOMAIN }} | ||
- name: Output template ID | ||
run: echo "Template ID: ${{ steps.build-template.outputs.template_id }}" | ||