Skip to content

Commit d61ac79

Browse files
committed
Fix secret passing to Docker during tests
- Create test.env file with API keys during test step - Pass both config.env and test.env to Docker container - Update README to emphasize UNCOMMENT requirement - This fixes 'OPENAI_API_KEY is not set' error during tests IMPORTANT: Projects must uncomment the env variables they need in deploy.yml!
1 parent a7ca45e commit d61ac79

File tree

3 files changed

+31
-7
lines changed

3 files changed

+31
-7
lines changed

.github/workflows/deploy.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,11 +243,22 @@ jobs:
243243
- name: Test Docker image with secrets
244244
run: |
245245
echo "🧪 Running full test suite with secrets..."
246-
# Docker automatically inherits env vars from the workflow env block
246+
# Create env file with all current environment variables that might be needed
247+
cat > test.env << EOF
248+
OPENAI_API_KEY=$OPENAI_API_KEY
249+
ANTHROPIC_API_KEY=$ANTHROPIC_API_KEY
250+
VERTEC_API_KEY=$VERTEC_API_KEY
251+
EOF
252+
253+
# Run tests with both config.env and test.env
247254
docker run --rm \
248255
--env-file deployment/config.env \
256+
--env-file test.env \
249257
${{ env.ECR_REPOSITORY }}:${{ github.sha }} \
250258
just test-all
259+
260+
# Clean up
261+
rm -f test.env
251262
echo "✅ All tests passed!"
252263
253264
- name: Push to ECR

.squirro/workflows/build-and-push-to-ecr.yml.template

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,11 +211,22 @@ jobs:
211211
- name: Test Docker image with secrets
212212
run: |
213213
echo "🧪 Running full test suite with secrets..."
214-
# Docker automatically inherits env vars from the workflow env block
214+
# Create env file with all current environment variables that might be needed
215+
cat > test.env << EOF
216+
OPENAI_API_KEY=$OPENAI_API_KEY
217+
ANTHROPIC_API_KEY=$ANTHROPIC_API_KEY
218+
VERTEC_API_KEY=$VERTEC_API_KEY
219+
EOF
220+
221+
# Run tests with both config.env and test.env
215222
docker run --rm \
216223
--env-file deployment/config.env \
224+
--env-file test.env \
217225
${{ env.ECR_REPOSITORY }}:${{ github.sha }} \
218226
just test-all
227+
228+
# Clean up
229+
rm -f test.env
219230
echo "✅ All tests passed!"
220231

221232
- name: Push to ECR

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -447,16 +447,18 @@ Each project must customize `.github/workflows/deploy.yml` to include its specif
447447

448448
1. Open `.github/workflows/deploy.yml`
449449
2. Find the `env:` block at the top (after the `on:` section)
450-
3. Add your project's secrets:
450+
3. **UNCOMMENT** and customize the secrets your project needs:
451451
```yaml
452452
env:
453-
# Your project's secrets
454-
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY || '' }}
455-
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY || '' }}
456-
CUSTOM_API_TOKEN: ${{ secrets.CUSTOM_API_TOKEN || '' }}
453+
# Example secrets (uncomment and modify for your project):
454+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY || '' }} # ← UNCOMMENT THIS!
455+
# ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY || '' }}
456+
# CUSTOM_API_TOKEN: ${{ secrets.CUSTOM_API_TOKEN || '' }}
457457
```
458458
4. Commit these changes - they're part of your project configuration
459459

460+
⚠️ **IMPORTANT**: The secrets are commented out by default. You MUST uncomment the ones you need!
461+
460462
**Why this approach?**
461463
- Simple and explicit - you see exactly what secrets your project uses
462464
- No complex template processing or filtering

0 commit comments

Comments
 (0)