100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace
CI/CD with GitHub Actions
30 minintermediate

Environments and Protection Rules

Deploying to production is fundamentally different from running tests. A test failure is recoverable — fix the code, push again. A bad production deployment can take down a live service serving millions of users, corrupt a database, or expose sensitive data. This difference in consequence demands a different governance model. GitHub Actions Environments provide that model: named deployment targets (staging, production, preview) with configurable protection rules that gate deployment job execution. Protection rules can require one or more specific reviewers to manually approve a deployment, restrict deployments to specific branches, enforce a wait timer before execution, and control which secrets are available. Environments transform deployment workflows from 'push code, it automatically goes everywhere' into 'push code, it automatically goes to staging, then waits for explicit human approval before production' — preserving automation speed for low-risk environments while enforcing human oversight for high-consequence ones.

Analogy🏏Cricket
🏏 Think of it like cricket: A cricket series is structured in three tiers: the series schedule (which matches are played and when), individual match plans (batting order, bowling rotations, fielding strategy), and specific delivery plans (which balls to bowl to which batsman in which over). The series schedule is the workflow — it defines the overall event. Each match is a job — it runs independently but contributes to the series outcome. Each delivery plan is a step — a specific action with a discrete result. Just as a Test captain doesn't redesign the series schedule for every match but does adjust the bowling plan for each innings, GitHub Actions separates what triggers the automation (workflow) from how independent tasks are parallelised (jobs) from the individual commands executed (steps). The insight is that this separation of concerns is what allows large, complex pipelines to remain manageable — just as a well-structured series plan keeps a touring team organised across multiple venues and formats.
Lesson 14 of 24
0% complete