- Published on
Revamping GitHub Actions Rules
- Authors

- Name
- Mamun Rashid
🔒 Guarding Production with Actions
Every software team lives with a trade-off between speed and security. We're expected to release often and get value to customers fast. We also have to protect production from honest mistakes that hurt service reliability or put customer data at risk, and that matters just as much. This post is about how we structured GitHub Actions rules and permissions to keep that balance.
The Challenge: Moving Fast Without Breaking Things
A few incidents taught me to be careful about who gets access to production-like environments. The most nerve-wracking one was the accidental destruction of multiple services in a Kubernetes cluster that was part of our staging environment. Luckily it wasn't production, but one mis-click and it could have been.
Another time, a critical deployment went wrong because of a misconfigured environment variable. A developer tried to fix it fast and accidentally introduced a bug that caused a partial outage. After that it was obvious we needed stricter controls and better safeguards around how we deploy. With more rigorous reviews and automated checks, we can significantly reduce the risk of incidents like these and keep production more stable.
It became clear that broad admin-level permissions were too risky. People with the best intentions still make mistakes. We needed a setup that made it nearly impossible for any one person to cause a major disruption by accident, while we kept shipping to customers quickly.
Guarding Environments 🛡️
Environment Secrets Management
Secrets for production-like environments need strict rules. Repository-level secrets such as DEPLOYMENT_PRIVATE_KEY, for example, are not allowed. Secrets live in GitHub "Environments" instead, so each environment (production, staging and so on) has its own set of secrets.
Each environment must have a clear, specific name like development, staging, or production. The name tells you the security level at a glance and helps avoid confusion about which environment a deployment is going to.

Deployment Protection Rules
Deployment protection rules are essential for production-like environments such as staging, which are meant to match production's stability and security. They stop unauthorized or risky changes from being deployed, which means fewer disruptions and smoother deployments. There are a few kinds:
Required reviewers are configurable for deployments. Code changes then have to be reviewed and approved by designated team members before they deploy, and that extra scrutiny helps catch bugs and security holes before they hit the environment. For production-like environments, a reviewer from the CloudOps team should sign off.
A deployment timer delays the deployment and gives the team a buffer to notice problems that don't show up right away. That leaves time for more testing, so last-minute problems are less likely to cause disruptions.
Custom rules can be built for your environment's needs, such as automated checks, security scans or compliance verifications. They hold deployments to the security and stability criteria that matter for that environment.

Overall Benefits:
Because they enforce reviews and testing, deployment protection rules help catch mistakes early and keep them out of critical environments. Security-focused rules, such as mandatory code reviews and compliance checks, lower the chance of a vulnerability reaching your production-like environments. Deployment timers and custom rules help make sure changes are well vetted and thoroughly tested, and that adds to the stability of the environment.
Branch Protection Rules: Safeguarding the Release Process
Restructuring permissions alone isn't enough. The deployment pipeline itself has to be trustworthy. Branch protection rules guard the release process by blocking unauthorized changes from being merged into protected branches. These are the ones worth enforcing:
Required Branch Protection
- All changes must go through pull requests (PRs) with enforced reviews from designated team members, so no code lands in a critical branch without a proper look. Every PR needs approval from the required number of reviewers before it can merge.

- The "Require review from Code Owners" rule in the
CODEOWNERSfile makes sure changes to specific files or directories get reviewed by the people who own them, which brings more expertise into the review.

- Administrators should not be able to bypass protection rules. With the bypass disabled, nobody, not even someone with elevated permissions, can merge code that hasn't met the required checks.

- Force pushes to protected branches are strictly disabled. That keeps the deployment pipeline intact.

- Required status checks, such as automated tests and code quality scans, have to pass before a PR can merge. That keeps the codebase reliable.

Share Your Stories and Feedback
Have you run into similar problems, or found your own way to manage permissions and deployments? Share your stories and feedback in the comments.
References:
Enjoyed this post?
Subscribe to get notified about new posts and updates. No spam, unsubscribe anytime.
By subscribing, you agree to our Privacy Policy. You can unsubscribe at any time.
Discussion
Loading comments...
This website is still under development. If you encounter any issues, please contact me.
Found this useful? Support the blog