Loading...
Loading...
Loading...
**Title:** Environment-Aware Builds & Secrets Management in Next.js | Production-Ready CI/CD
# Video Script: Environment-Aware Builds & Secrets Management
**Title:** Environment-Aware Builds & Secrets Management in Next.js | Production-Ready CI/CD
**Duration:** 3-5 minutes
**Target Audience:** Developers learning production deployment best practices
**Style:** Professional technical walkthrough with live demonstrations
---
## Pre-Recording Checklist
### Technical Setup
- [ ] VS Code open with project structure visible
- [ ] Terminal ready for command demonstrations
- [ ] GitHub repository open in browser
- [ ] All `.env` files created and ready to show
- [ ] GitHub Secrets configured
- [ ] Workflows tested and working
### Recording Setup
- [ ] Screen recording software ready (OBS Studio / Loom)
- [ ] Microphone tested
- [ ] Close unnecessary applications
- [ ] Quiet environment
- [ ] 1080p resolution minimum
- [ ] Cursor highlighter enabled
### VS Code Preparation
- [ ] Font size increased (for readability)
- [ ] Color theme with good contrast
- [ ] Terminal visible at bottom
- [ ] File tree expanded to show structure
- [ ] All necessary files open in tabs
---
## SCENE 1: Introduction & Hook (0:00 - 0:30)
### Visual: VS Code with project structure
### Script:
"Hey everyone! In this video, I'm going to show you how I implemented environment-aware builds and secure secrets management in my Next.js application—a critical skill for any production deployment."
**[Show file tree highlighting .env files]**
"We'll cover how to create separate environment files for development, staging, and production, how to use GitHub Secrets to keep credentials secure, and how to set up automated CI/CD workflows that use the correct secrets based on which branch you're deploying from."
**[Quick flash of the final working system]**
"By the end, you'll know how to build a system that makes it impossible to accidentally use staging secrets in production—a mistake that costs companies thousands of dollars every day."
"Let's dive in!"
---
## SCENE 2: The Problem We're Solving (0:30 - 1:00)
### Visual: Show hypothetical bad setup with annotations
### Script:
"First, let's talk about why this matters. Many developers make a critical mistake: they use a single `.env` file for all environments."
**[Show single .env file with problems highlighted in red]**
"This leads to three major problems:"
**[Annotate on screen as you speak:]**
**Problem 1:** "Accidentally using test API keys in production—imagine processing real payments with sandbox credentials."
**Problem 2:** "Committing secrets to Git where they're exposed forever in your Git history, even if you delete them later."
**Problem 3:** "Manual deployments where you have to remember to change 20+ environment variables before deploying—human error is inevitable."
**[Show news headline about API key leak]**
"In 2024 alone, over 10 million secrets were leaked on GitHub. One company lost $15,000 in 30 minutes because of this exact mistake."
"Let's build a system that makes these mistakes architecturally impossible."
---
## SCENE 3: Separate Environment Files (1:00 - 1:45)
### Visual: Create and show four .env files
### Script:
"I created four separate environment files. Let me walk you through each one."
**[Open .env.development]**
"First, `.env.development` for local development. This uses localhost URLs and test API keys—completely safe for experimenting on your machine."
**[Highlight key variables:]**
```
NEXT_PUBLIC_API_URL=http://localhost:3000/api
STRIPE_SECRET_KEY=sk_test_dev_key_here
NEXT_PUBLIC_ENABLE_DEBUG=true
```
"Notice debug mode is enabled and we're using test Stripe keys."
**[Open .env.staging]**
"Next, `.env.staging` for our testing environment. This mimics production but still uses sandbox API keys so we can test safely."
**[Highlight:]**
```
NEXT_PUBLIC_API_URL=https://staging-api.yourapp.com
STRIPE_SECRET_KEY=sk_test_staging_key
DATABASE_NAME=nextapp_staging
```
"Staging database, staging API, but still in test mode."
**[Open .env.production]**
"Then `.env.production` for our live environment. This has real credentials—live payment processing, production database, debug mode disabled."
**[Highlight:]**
```
NEXT_PUBLIC_API_URL=https://api.yourapp.com
STRIPE_SECRET_KEY=sk_live_production_key
NEXT_PUBLIC_ENABLE_DEBUG=false
```
"This is where real money flows, so security is critical."
**[Open .env.example]**
"Finally, `.env.example` is just a template with placeholder values and no real secrets. This is the ONLY file I commit to GitHub."
**[Show file:]**
```
STRIPE_SECRET_KEY=your_stripe_secret_key
DATABASE_URL=your_database_connection_string_here
```
"Team members can copy this and fill in their own credentials without me ever having to share secrets directly."
**[Open .gitignore]**
"My `.gitignore` protects all the real secret files but allows `.env.example` through."
**[Highlight:]**
```gitignore
# Protect secrets
.env
.env.development
.env.staging
.env.production
# Allow template
!.env.example
```
"This way secrets never touch Git, never appear in history, and can never be leaked."
---
## SCENE 4: GitHub Secrets Setup (1:45 - 2:30)
### Visual: Navigate to GitHub repository settings
### Script:
"Real secrets live in GitHub Secrets, not in my code. Let me show you how I organized them."
**[Navigate: Repository → Settings → Secrets and variables → Actions]**
"GitHub Secrets provides encrypted storage for sensitive information used in CI/CD workflows."
**[Show secrets list]**
"I use prefixes to make it crystal clear which environment each secret belongs to."
**[Point to secrets as you explain:]**
"All staging secrets start with `STAGING_` underscore:"
- `STAGING_STRIPE_SECRET_KEY` - sandbox key for testing
- `STAGING_DATABASE_URL` - staging database
- `STAGING_JWT_SECRET` - staging authentication
"And all production secrets start with `PROD_` underscore:"
- `PROD_STRIPE_SECRET_KEY` - live key for real payments
- `PROD_DATABASE_URL` - production database
- `PROD_JWT_SECRET` - production authentication
**[Click on one secret to show it's encrypted]**
"See how it's encrypted? Even I can't view the value once it's saved. GitHub encrypts these secrets, and they're only available during CI/CD workflows—they never appear in code or logs."
**[Show creating a new secret]**
"To add a secret, I click 'New repository secret', give it a name with the right prefix, paste the value, and save. That's it."
"This separation is crucial: staging uses test keys, production uses live keys, and they're completely isolated."
---
## SCENE 5: CI/CD Workflows (2:30 - 3:15)
### Visual: Show .github/workflows directory
### Script:
"Now here's where the magic happens. I have two GitHub Actions workflows: one for staging, one for production."
**[Open .github/workflows/deploy-staging.yml]**
"The staging workflow is triggered automatically when I push to the `staging` branch."
**[Highlight trigger:]**
```yaml
on:
push:
branches:
- staging
```
"See that? It's listening for pushes to staging branch only."
**[Scroll to secret injection section]**
"Then it automatically injects the `STAGING_*` secrets into a `.env.staging` file."
**[Highlight:]**
```yaml
DATABASE_URL: ${{ secrets.STAGING_DATABASE_URL }}
STRIPE_SECRET_KEY: ${{ secrets.STAGING_STRIPE_SECRET_KEY }}
```
"GitHub Actions pulls these from the secrets we just saw and creates the environment file dynamically. No manual intervention, no room for error."
**[Highlight build command:]**
```yaml
run: npm run build:staging
```
"Then it builds the app using that staging environment."
**[Open .github/workflows/deploy-production.yml]**
"The production workflow works the same way but only triggers on the `main` branch and uses `PROD_*` secrets."
**[Highlight:]**
```yaml
on:
push:
branches:
- main
DATABASE_URL: ${{ secrets.PROD_DATABASE_URL }}
STRIPE_SECRET_KEY: ${{ secrets.PROD_STRIPE_SECRET_KEY }}
```
**[Show diagram: branch → workflow → secrets]**
"So the flow is: push to staging branch triggers staging workflow which uses staging secrets. Push to main branch triggers production workflow which uses production secrets."
"The key insight: staging workflow physically cannot access production secrets because of GitHub Actions environment permissions. Complete isolation."
---
## SCENE 6: Local Verification (3:15 - 4:00)
### Visual: Terminal commands
### Script:
"Before trusting this in production, I verified it works locally. Watch:"
**[Type command:]**
```bash
npm run build:staging
```
**[As build runs, explain:]**
"This command uses the `dotenv-cli` package to load `.env.staging` and then builds the app."
**[Show successful build output]**
"Build succeeds! Now let me verify the configuration:"
**[Run verification command:]**
```bash
npm run env:verify
```
**[Show verification output:]**
```
🔍 Environment Variables Verification
📌 Current Configuration:
NEXT_PUBLIC_ENVIRONMENT: staging
API URL: https://staging-api.yourapp.com
Database: nextapp_staging
✅ Using staging configuration
```
"Perfect! Staging environment confirmed."
**[Now run production build:]**
```bash
npm run build:production
```
**[Show output:]**
```
🔍 Environment Variables Verification
📌 Current Configuration:
NEXT_PUBLIC_ENVIRONMENT: production
API URL: https://api.yourapp.com
Database: nextapp_prod
🔒 Using production secrets
```
"Production build using production configuration. Everything's correct."
**[Show package.json scripts:]**
```json
"build:staging": "dotenv -e .env.staging next build"
"build:production": "dotenv -e .env.production next build"
```
"These scripts make it easy to test each environment locally before deploying."
---
## SCENE 7: The Real-World Impact (4:00 - 4:30)
### Visual: Show case study summary slide
### Script:
"Let me tell you why this matters in the real world."
**[Show headline: "The Staging Secret That Broke Production"]**
"A payment processing company accidentally used staging Stripe keys in production. Result?"
**[Show statistics:]**
- "30 minutes of failed payments"
- "$15,000 in lost revenue"
- "47 angry customers"
- "Weekend emergency deployment"
**[Show root cause:]**
"The cause? They used a single `.env` file and manually edited it before deploying. The developer forgot to change one variable—the Stripe API key—and production started using test credentials."
**[Show your system diagram]**
"My system makes that incident impossible because:"
**[Enumerate:]**
"One: Separate files mean you can't mix up staging and production."
"Two: Automated secret injection eliminates manual steps entirely."
"Three: Branch-based workflows ensure staging secrets never touch production."
"Four: Verification scripts catch configuration errors before deployment happens."
**[Show comparison table]**
"Manual process: high error risk. Automated process: near-zero error risk."
"It's not just about security—it's about reliability, confidence, and peace of mind."
---
## SCENE 8: Quick Recap & Implementation (4:30 - 5:00)
### Visual: Checklist animation
### Script:
"Let's recap what we built:"
**[Show checklist with checkmarks appearing:]**
"✅ Separate environment files: development, staging, production, and example"
"✅ Secrets protected by `.gitignore`—never committed to Git"
"✅ Real secrets stored securely in GitHub Secrets with clear prefixes"
"✅ Automated CI/CD workflows that use correct secrets based on branch"
"✅ Verification scripts that catch errors before deployment"
"✅ Complete isolation: staging workflow can't access production secrets"
**[Show final project structure]**
"The result? A production-ready system that's secure, automated, and reliable."
**[Show implementation steps:]**
"To implement this yourself:"
"1. Create separate `.env` files for each environment"
"2. Update `.gitignore` to protect secrets"
"3. Set up GitHub Secrets with prefixed names"
"4. Create branch-based GitHub Actions workflows"
"5. Test locally with environment-specific build commands"
**[Show repository link]**
"All the code is in my GitHub repository—link in the description."
---
## SCENE 9: Closing (5:00 - 5:15)
### Visual: Back to camera / final slide
### Script:
"Environment-aware builds and proper secrets management aren't optional in production—they're essential."
"This approach eliminates entire classes of errors, protects your credentials, and makes deployments reliable and stress-free."
**[Smile]**
"No more manual deployments, no more secret leaks, no more production incidents from configuration mistakes."
"If you found this helpful, give it a thumbs up, and let me know in the comments if you have questions about implementing this in your own projects."
"Thanks for watching, and I'll see you in the next video!"
**[End screen with subscribe button and related video suggestions]**
---
## Post-Production Editing Notes
### Cuts & Timing
- Remove long pauses between sentences
- Speed up terminal output (show command, then fast-forward to result)
- Use smooth transitions between scenes
- Add 2-second buffer at start and end for music fade
### Visual Enhancements
#### Annotations
- Highlight important code lines with colored boxes
- Add arrows pointing to key concepts
- Use checkmarks (✅) and X marks (❌) for good/bad examples
- Zoom in on small text (environment variables, secrets)
#### B-Roll
- Diagram showing branch routing (draw in PowerPoint/Figma)
- Comparison table (manual vs automated)
- Case study summary slide
- Implementation checklist with animated checkmarks
#### Text Overlays
- Key terms in lower third (e.g., "GitHub Secrets", "Branch-Based Routing")
- Statistics (e.g., "10M+ secrets leaked in 2024")
- Code snippets for emphasis
- Links to resources
### Audio
#### Music
- Intro: Upbeat tech background music (low volume)
- Main content: Subtle background music or silence
- Outro: Return to upbeat music
#### Sound Effects (Optional)
- Success sound for checkmarks
- Alert sound for problems/warnings
- Click sound for transitions
#### Audio Quality
- Normalize audio levels
- Remove background noise
- Add slight compression for consistent volume
### Color Grading
- Increase screen visibility if needed
- Ensure code is readable
- Consistent brightness throughout
### Captions
- Add subtitles for accessibility
- Highlight key terms in different color
- Sync perfectly with speech
---
## YouTube Optimization
### Title Options
1. "Environment-Aware Builds & Secrets Management in Next.js | Production CI/CD"
2. "Stop Leaking Secrets! Proper Environment Management in Next.js"
3. "How I Secured My Next.js App: Environment Variables & GitHub Secrets"
### Description
```
🔐 Learn how to implement environment-aware builds and secure secrets management in your Next.js application!
In this video, I walk through my complete setup for managing development, staging, and production environments, including:
✅ Separate .env files for each environment
✅ GitHub Secrets for secure credential storage
✅ Automated CI/CD with branch-based deployments
✅ Verification scripts to catch errors before production
✅ Real-world case study: how this prevents costly incidents
🔗 Repository: [Your GitHub Link]
📄 Full Documentation: [Your Docs Link]
⏱️ Timestamps:
0:00 - Introduction
0:30 - The Problem
1:00 - Environment Files Setup
1:45 - GitHub Secrets
2:30 - CI/CD Workflows
3:15 - Local Verification
4:00 - Real-World Impact
4:30 - Quick Recap
5:00 - Closing
💡 Key Concepts:
- Environment segregation
- Secret management
- GitHub Actions workflows
- Branch-based deployments
- Automated verification
🛠️ Technologies:
- Next.js
- GitHub Actions
- GitHub Secrets
- MongoDB Atlas
- Stripe API
📚 Related Videos:
[Link to related content]
#NextJS #WebDevelopment #DevOps #CICD #SecretManagement #GitHub #Programming
```
### Tags
nextjs, web development, ci/cd, github actions, secret management, environment variables, devops, deployment, github secrets, stripe, mongodb, production deployment, staging environment, tutorial, programming, software engineering
### Thumbnail Design
- Screenshot of VS Code with environment files
- Large text: "Stop Leaking Secrets!"
- Your face (if comfortable) for personal connection
- High contrast, readable at small size
- Red X over bad practice, green checkmark over good practice
---
## Presentation Tips
### Speaking Style
- **Pace:** Moderate speed; not too fast (allows editing flexibility)
- **Tone:** Professional but approachable
- **Energy:** Enthusiastic but not over-the-top
- **Clarity:** Enunciate technical terms clearly
### On-Screen Presence
- **Cursor:** Move deliberately; don't wave around
- **Scrolling:** Smooth and slow; viewers need time to read
- **Typing:** Either type naturally or paste (avoid slow typing that's edited out)
- **Highlighting:** Use mouse or cursor to point at important code
### Common Pitfalls to Avoid
- ❌ Saying "um", "uh" repeatedly (pause silently instead; edit out pauses)
- ❌ Scrolling too fast
- ❌ Assuming viewer sees what you see (explicitly point things out)
- ❌ Leaving mistakes in (edit them out or restart section)
- ❌ Inconsistent audio levels (test before full recording)
### Pro Tips
- ✅ Record in short segments (easier to edit)
- ✅ Use takes: if you mess up, pause, then restart that sentence
- ✅ Leave 2 seconds of silence at cuts (easier editing)
- ✅ Smile! Even in audio-only, it comes through in your voice
- ✅ Test everything before recording (commands should work first try)
---
## Alternative Versions
### Short Version (90 seconds)
Focus on:
- Problem statement (30s)
- Solution overview (30s)
- Real-world impact (30s)
### Long Version (10 minutes)
Add:
- Live GitHub Actions deployment
- More detailed explanation of workflows
- Additional verification techniques
- Q&A style addressing common questions
### Series Format
Split into 3 videos:
1. Environment Files & .gitignore
2. GitHub Secrets & Workflow Setup
3. Verification & Real-World Case Study
---
## Final Checklist Before Publishing
- [ ] Video renders at 1080p or higher
- [ ] Audio is clear and normalized
- [ ] All code is visible and readable
- [ ] Annotations are accurate
- [ ] Links in description work
- [ ] Thumbnail is eye-catching
- [ ] Title is SEO-optimized
- [ ] Tags are relevant
- [ ] Captions added (auto-generate then review)
- [ ] End screen added with subscribe button
- [ ] Video tested on mobile (readability check)
---
**Good luck with your recording! You've got this! 🎥**
---
**Total Script Word Count:** ~2,400 words
**Estimated Speaking Time:** 5 minutes (at ~480 words per minute with pauses)
**Recommended Total Video Length:** 5-6 minutes (with visual demonstrations)
---
[](http://colab.research.google.com/github/rinongal/stylegan-nada/blob/main/stylegan_nada.ipynb)
get signed picture and voice authorisations from our parents
Parses a structured video script, extracts all `Narrator:` blocks, and synthesises them into a single MP3 using Azure OpenAI TTS.
<img src="https://img.shields.io/github/forks/artkulak/text2youtube.svg">