Skip to content

Commit 055fa33

Browse files
committed
Add env selection to prod build workflow
1 parent 5cb8bd5 commit 055fa33

File tree

1 file changed

+57
-3
lines changed

1 file changed

+57
-3
lines changed

.github/workflows/build_prod_template.yml

Lines changed: 57 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@ name: Build Prod Template
33
on:
44
workflow_dispatch:
55
inputs:
6+
target_environment:
7+
description: Target environment
8+
required: true
9+
type: choice
10+
default: foxtrot
11+
options:
12+
- foxtrot
13+
- staging
14+
- juliett
615
skip_cache:
716
description: Skip build cache
817
required: false
@@ -33,18 +42,63 @@ jobs:
3342

3443
- uses: actions/setup-python@v6
3544
with:
36-
python-version: '${{ env.TOOL_VERSION_PYTHON }}'
45+
python-version: '${{ env.TOOL_VERSION_PYTHON }}'
3746

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

51+
- name: Resolve target environment
52+
env:
53+
TARGET_ENVIRONMENT: ${{ inputs.target_environment }}
54+
FOXTROT_API_KEY: ${{ secrets.E2B_PROD_API_KEY }}
55+
STAGING_API_KEY: ${{ secrets.E2B_STAGING_API_KEY }}
56+
JULIETT_API_KEY: ${{ secrets.E2B_JULIETT_API_KEY }}
57+
run: |
58+
set -eu
59+
60+
case "$TARGET_ENVIRONMENT" in
61+
foxtrot)
62+
E2B_DOMAIN="e2b.dev"
63+
E2B_API_KEY="$FOXTROT_API_KEY"
64+
;;
65+
staging)
66+
E2B_DOMAIN="e2b-staging.dev"
67+
E2B_API_KEY="$STAGING_API_KEY"
68+
;;
69+
juliett)
70+
E2B_DOMAIN="e2b-juliett.dev"
71+
E2B_API_KEY="$JULIETT_API_KEY"
72+
;;
73+
*)
74+
echo "Unknown target environment: $TARGET_ENVIRONMENT" >&2
75+
exit 1
76+
;;
77+
esac
78+
79+
if [ -z "$E2B_API_KEY" ]; then
80+
echo "Missing API key secret for target environment: $TARGET_ENVIRONMENT" >&2
81+
exit 1
82+
fi
83+
84+
echo "::add-mask::$E2B_API_KEY"
85+
86+
{
87+
echo "E2B_DOMAIN=$E2B_DOMAIN"
88+
echo "E2B_API_KEY=$E2B_API_KEY"
89+
} >> "$GITHUB_ENV"
90+
91+
{
92+
echo "### Build target"
93+
echo
94+
echo "Target: $TARGET_ENVIRONMENT"
95+
echo "Domain: $E2B_DOMAIN"
96+
} >> "$GITHUB_STEP_SUMMARY"
97+
4298
- name: Build E2B template
4399
id: build-template
44100
working-directory: ./template
45101
run: |
46102
python build_prod.py
47103
env:
48-
E2B_API_KEY: ${{ secrets.E2B_PROD_API_KEY }}
49-
E2B_DOMAIN: ${{ vars.E2B_DOMAIN }}
50104
SKIP_CACHE: ${{ inputs.skip_cache }}

0 commit comments

Comments
 (0)