DEV Community
Follow
A Simple CI/CD Pipeline That Actually Works
Most CI/CD tutorials oversimplify by focusing on basic deployments, neglecting crucial aspects like secrets management and rollbacks. The author advocates for a straightforward, three-stage pipeline: Test, Build, and Deploy, using GitHub Actions for accessibility. The process begins with automated tests that must pass before any build or deployment occurs. Only pushes to the main branch trigger the build stage, which compiles the application into an artifact. The deploy stage then transfers this artifact to the server using SCP, requiring secure management of server credentials as GitHub secrets. To enable quick rollbacks, the author suggests keeping the last three deployment versions on the server. Dependency consistency is maintained by using lockfiles, ensuring reproducible builds across environments. Before committing, local testing of tests and build steps is recommended to catch issues early. Common problems include incorrect SSH key formats, path mismatches in build output, and insufficient server path permissions for the deploy user. Additional features like linting or database migrations can be added later, prioritizing simplicity and ease of debugging. This minimalist approach is suitable for many projects, emphasizing iterative development and starting with a functional core.