Deploy to Production: A Guide to Safe, Automated Releases
The stages of deploying code to production, from development to staging to live, the difference between deploy and release, and how to automate releases with approvals and rollbacks.
TL;DR — Deploying to production means moving verified code into the live environment that users rely on. Safe teams promote the same build through dev and staging, separate deploy from release with feature flags or canaries, gate production behind tests and approvals, and keep a tested rollback ready for when something breaks.
Moving new code from a developer’s machine to a live, user-facing application is where most outages start. Configuration errors, missed migrations, and breaking changes all surface at this step, so the way a team deploys matters as much as what it deploys.
This guide covers the stages of a production deployment, the difference between deploying and releasing, and how to automate the pipeline with approvals and rollbacks.
How Production Deployment Works: Stages and Concepts
At its core, deploying to production means making your latest code changes live. This process involves several distinct environments and a clear understanding of key terms.
A typical software delivery pipeline moves code through a sequence of environments:
- Development (Dev): This is where developers write and test code on their local machines or in a shared sandboxed environment. The focus is on feature implementation and unit testing.
- Staging: A pre-production environment that mirrors the production setup as closely as possible. Code from multiple developers is integrated here for quality assurance (QA), integration testing, and user acceptance testing (UAT). Staging is the final gate before a change is approved for production.
- Production (Prod): The live environment that end-users interact with. Code that reaches this stage has been thoroughly tested and verified. Deployments to production must be handled with care to avoid service disruptions.
It also helps to distinguish deploying from releasing. A deployment installs a specific version of software into an environment. A release makes that software available to users. Feature flags and canary releases let teams deploy new code to production without exposing it to everyone at once, separating the technical rollout from the business decision.
Why Production Deployment Needs Orchestration
As applications grow, manual deployments become brittle and risky. A simple git pull on a server doesn’t account for database migrations, configuration updates, service dependencies, or the need for a rollback if something goes wrong. This is where orchestration becomes essential.
Orchestration automates and coordinates the entire deployment workflow, treating it as a single, manageable process. Here is what it adds to production deployments:
- Dependency Management: Modern applications rely on a web of services, databases, and APIs. An orchestrator ensures that all dependencies are met in the correct order, preventing failures caused by missing components.
- Automated Checks and Gates: A deployment pipeline should include automated unit tests, integration tests, security scans, and performance checks. Orchestration tools run these checks at each stage and halt the deployment if any check fails.
- Visibility and Auditability: An orchestration platform provides a centralized view of all deployments, showing what was deployed, when, by whom, and whether it succeeded. This audit trail is invaluable for compliance and troubleshooting.
- Automated Rollbacks: If a deployment fails or introduces a critical bug, an orchestrator can automatically trigger a rollback to the last known good version, minimizing downtime.
- Integrated Approvals: For critical systems, a manual approval step before a production deploy adds a layer of human oversight. Orchestration platforms can manage these approvals within the automated workflow, pausing the process until a designated team member gives the green light. The concept of CI/CD for data pipelines extends these principles to data-centric workflows as well.
The DORA research program links frequent, reliable deployments to automated delivery practices such as CI/CD orchestration. By treating your deployment pipeline as everything as code, you make it versionable, repeatable, and less prone to human error.
Orchestrate Your Production Deployment with Kestra: A CI/CD Pipeline Example
A declarative orchestrator like Kestra lets you define the whole multi-stage pipeline in one YAML file. This example is triggered by a push webhook from the Git provider: it builds and tests the pushed commit, pushes one image tagged with the commit SHA, deploys that image to staging, runs integration tests, pauses for approval, then deploys the same image to production, with a rollback that only runs if the production step fails.
id: cicd-pipeline-with-approvalnamespace: company.team.cicd
triggers: - id: github_push type: io.kestra.plugin.core.trigger.Webhook key: "{{ secret('DEPLOY_WEBHOOK_KEY') }}" when: "{{ trigger.body.ref == 'refs/heads/main' }}"
tasks: - id: build_and_stage type: io.kestra.plugin.core.flow.WorkingDirectory tasks: - id: clone_for_staging type: io.kestra.plugin.git.Clone url: https://github.com/your-org/my-app.git commit: "{{ trigger.body.after }}" username: "{{ secret('GITHUB_USERNAME') }}" password: "{{ secret('GITHUB_TOKEN') }}"
- id: build_and_test type: io.kestra.plugin.scripts.shell.Commands containerImage: eclipse-temurin:21 commands: - ./gradlew build test
- id: push_image type: io.kestra.plugin.docker.cli.Build dockerfile: Dockerfile tags: - "registry.example.com/my-app:{{ trigger.body.after }}" push: true credentials: registry: registry.example.com username: "{{ secret('REGISTRY_USERNAME') }}" password: "{{ secret('REGISTRY_PASSWORD') }}"
- id: deploy_to_staging type: io.kestra.plugin.scripts.shell.Commands containerImage: eclipse-temurin:21 commands: - ./deploy.sh staging "registry.example.com/my-app:{{ trigger.body.after }}"
- id: run_integration_tests type: io.kestra.plugin.scripts.shell.Commands containerImage: eclipse-temurin:21 commands: - ./run-tests.sh staging
- id: approval_gate type: io.kestra.plugin.core.flow.Pause description: Review the staging deployment, then resume to release to production. pauseDuration: PT4H behavior: CANCEL
- id: release_to_production type: io.kestra.plugin.core.flow.WorkingDirectory tasks: - id: clone_for_production type: io.kestra.plugin.git.Clone url: https://github.com/your-org/my-app.git commit: "{{ trigger.body.after }}" username: "{{ secret('GITHUB_USERNAME') }}" password: "{{ secret('GITHUB_TOKEN') }}"
- id: deploy_to_production type: io.kestra.plugin.scripts.shell.Commands containerImage: eclipse-temurin:21 commands: - ./deploy.sh production "registry.example.com/my-app:{{ trigger.body.after }}" errors: - id: rollback_production type: io.kestra.plugin.scripts.shell.Commands containerImage: eclipse-temurin:21 commands: - ./rollback.sh production
- id: notify_success type: io.kestra.plugin.slack.notifications.SlackIncomingWebhook url: "{{ secret('SLACK_WEBHOOK_URL') }}" payload: | {"text": "Production deployment of {{ trigger.body.after }} succeeded (execution {{ execution.id }})."}
errors: - id: notify_failure type: io.kestra.plugin.slack.notifications.SlackIncomingWebhook url: "{{ secret('SLACK_WEBHOOK_URL') }}" payload: | {"text": "Deployment pipeline failed for {{ trigger.body.after }} (execution {{ execution.id }}). Check the logs; production is rolled back only if the production step failed."}What’s worth noticing in this flow:
- Declarative Pipeline: The entire deployment process is defined in one YAML file, making it easy to version, review, and understand. The
push_imagetask builds the pushed commit once and tags the image with its SHA; both deploy steps deploy that tag, so production runs the exact artifact staging tested. Both stages clone the same commit with the Git plugin only to get the deploy scripts. Thewhencondition on the trigger ignores pushes to other branches and tags. - Human-in-the-Loop Approval: The
Pausetask creates a manual approval gate. The workflow stops and waits for a team member to resume it from the UI or API. If nobody approves within four hours, the execution is cancelled and nothing reaches production. A cancellation is not a failure, sonotify_failuredoes not run and no Slack message is sent; setbehavior: FAILif a timed-out approval should alert. - Scoped Rollback: The rollback is attached to the production
WorkingDirectoryonly, so a failed build or staging test never triggers a production rollback. The flow-levelerrorsblock sends the Slack alert for any failure. - Integrated Notifications: The workflow communicates its status directly to a Slack channel, providing immediate visibility into both successful and failed deployments without requiring anyone to check a dashboard.
Choosing Your Deployment Strategy: Automated vs. Manual Gates
The example above includes a manual approval gate, a common practice for critical systems. Many DevOps teams aim to build enough confidence in automated tests to remove that step and move to continuous deployment. Platforms such as GitHub offer similar environment protection rules for teams that deploy from Actions.
The decision depends on your risk tolerance, the maturity of your test suite, and compliance requirements. A human-in-the-loop orchestration model is a middle ground, allowing you to automate everything except the final go-live decision. As your confidence grows, you can convert the Pause task into another automated check.
Ready to orchestrate your infrastructure?
Where Automated Deployments Pay Off: Key Use Cases
Automating your deployment process is more than just a technical exercise; it delivers tangible business value across various scenarios:
- Web Application Releases: Deploy new features, bug fixes, and security patches to your user-facing web apps multiple times a day with confidence.
- Infrastructure as Code (IaC) Rollouts: Apply
terraformoransiblechanges through a governed pipeline, ensuring that infrastructure modifications are tested and approved before affecting production. This aligns with GitOps principles where the Git repository is the single source of truth for both application and infrastructure code. - Machine Learning Model Deployment: Safely promote new ML models from training to production, ensuring data contracts are met and model performance is validated before serving live traffic.
- Database Migrations: Coordinate schema changes with application deployments, preventing mismatches and ensuring data integrity.
By automating provisioning and deployment, you reduce manual toil, increase release velocity, and build more resilient systems.
Related Concepts
- Pipeline as Code: A Guide to Versioning Your Workflows
- Model Deployment: Process, Strategies & Orchestration
- Deploying Kestra flows themselves: Kestra CI/CD Pipelines
- Deploying Kestra flows themselves: CI/CD for Kestra Flows Blueprint
Ready to automate your production deployments? See the Kestra homepage or get started with the open-source edition.
Terraform, Ansible and Kubernetes, orchestrated from one place.
Related resources
Frequently asked questions
Find answers to your questions right here, and don't hesitate to Contact Us if you couldn't find what you're looking for.