A complete production pipeline does more than just run tests. It validates code across multiple operating systems and runtime versions (Matrix Builds), securely injects production credentials via GitHub Secrets, builds Docker container images, and executes zero-downtime deployments.
If you build an open-source library or enterprise API, you must guarantee that your code runs identically across multiple Node.js or Python versions and operating systems. Matrix Builds handle this with concise syntax:
jobs:
test-matrix:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
node-version: [18.x, 20.x, 22.x]
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }} on ${{ matrix.os }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm test
This single workflow automatically spawns 9 parallel jobs (3 OSes × 3 Node versions)!
secrets.*)Never commit production API keys, AWS tokens, or database URLs in your YAML workflow files. Store them in GitHub Encrypted Secrets:
AWS_ACCESS_KEY_ID, Value: AKIAIOSFODNN7EXAMPLE.Reference the encrypted secret in your workflow:
- name: Deploy to Cloud
env:
AWS_KEY: ${{ secrets.AWS_ACCESS_KEY_ID }}
DB_URL: ${{ secrets.DATABASE_PRODUCTION_URL }}
run: |
./scripts/deploy.sh
needs:)Ensure that deployment only runs if testing and linting jobs succeed:
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm ci && npm test
deploy:
needs: test # Only runs if 'test' completes successfully!
if: github.ref == 'refs/heads/main' # Only deploy from main branch
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Deploy to Production
run: echo "Deploying version ${{ github.sha }} to production servers..."
Strengthen your version control mastery by studying these connected classes:
Review workflow triggers, runner virtual environments, and YAML syntax.
Guarantee that only tested, verified code enters your production main branch.
Adopt modern continuous integration and continuous deployment paradigms.
Build a complete GitHub Actions YAML workflow from scratch with automated testing.
Advance your software engineering skills with the next topic in our synchronized curriculum.
Continue to Branch Protection & Rules → Previous: ← GitHub Actions Intro | Full Syllabus