Sobes.tech
Middle+

Do you think it is correct to combine build, testing, and image deployment to the artifact storage in a single workflow, as well as adding steps for deployment to various environments?

sobes.tech AI

Answer from AI

This is not always optimal. While such an approach can be convenient for small projects or local test builds, combining all stages into one workflow has disadvantages:

  • Reduced flexibility: Deploying to different environments (dev, staging, production) requires different parameters and often different access rights. Combining them complicates managing these differences.
  • Environment dependency: If deployment to one of the environments fails, the entire build is considered failed, even if the image build and testing were successful.
  • Rollback complexity: Rolling back deployment becomes less trivial, as you need to revert the entire workflow.
  • Increased execution time: The entire pipeline takes more time, slowing down feedback for developers.
  • Less scalability: As the project grows and the number of deployment environments increases, such a workflow becomes cumbersome and hard to manage.

A more common and flexible practice is to separate these stages:

  1. Build & Test Pipeline: Responsible for code compilation, testing, image building, and storing it in an artifact registry (e.g., Docker Registry, Nexus). This workflow runs on each commit or pull request.
  2. Deployment Pipelines: Separate workflows for deploying to each environment. They take the already built and tested image from the artifact registry and deploy it to the target environment. These workflows can be triggered manually, on a schedule, or automatically after the successful completion of the previous stage (e.g., successful deployment to staging).

This allows:

  • Faster feedback on code quality (build & test).
  • Deploying to different environments independently.
  • More flexible management of deployment parameters for each environment.
  • Simplified rollback process.

Exceptions may include small pet projects or monolithic applications with a simple deployment process, where the overhead of separation exceeds the benefits. However, in most corporate environments, separating workflows is considered best practice.