Urgent.News

What's breaking now, across thousands of outlets.

Tech

De "Merge é Deploy" para Release Engineering com GitHub Actions

Você já parou pra pensar no risco de manter uma esteira onde qualquer merge na branch principal vai direto pra produção sem nenhum gate de segurança? Por muito tempo, o nosso fluxo aqui era aquele clássico script que quase todo mundo já usou na vida: merge na main disparando SSH com git pull e pm2 restart Funcionava no dia a dia, mas era aquela falsa sensação de estabilidade kkkk A ficha caiu de…

The article discusses the risks of maintaining a continuous integration pipeline where any merge to the main branch is automatically deployed to production without any security checks. The author shares how their team's previous workflow, which involved a script that merged the main branch and restarted the application using SSH, led to a false sense of stability.

This changed when the author discovered a critical oversight in the automation: remote scripts lacked strict error handling. If a git pull generated a conflict or a database migration failed midway, the script would ignore the error, complete the process, and mark the GitHub Actions pipeline as successful.

The author highlights how this approach created significant issues. For instance, monitoring indicated that everything ran smoothly when in reality the application was down in production. Additionally, the order of operations was incorrect, as the database migration ran before the application build. If TypeScript caught a type error during the build, the database had already been altered, making it impossible to roll back the changes.

Prisma, the database migration tool used, did not have native down migrations, so reverting the state would require manual, high-risk intervention.

To address these problems, the author decided to redesign the entire delivery architecture from scratch, starting with the clear premise that a tag signifies a release, not a merge. Now, nothing touches the server without an annotated SemVer tag, passing through six sequential stages: strict validation of the tag, ensuring it follows the vX.Y.Z format, automated testing with Vitest, rigorous type checking, building, and validating database migrations.

A backup routine runs daily, supplemented by a mandatory snapshot before any infrastructure changes. A real migration rehearsal is also implemented, where the pipeline restores a production dump on a disposable database within the VPS, runs the scheduled migration, and checks for schema drift before touching the official database.

The final stage is deterministic deployment, which involves checking out directly from the immutable tag, building before migration, and locking concurrency to prevent simultaneous deployments. The impact of this change has been profound, providing real predictability in migrations, traceability of each version, and certainty that a green pipeline means an intact system in production.

For those managing Node and TypeScript applications on VPS or dedicated servers looking to move away from "blind deployments," the author has structured this entire architecture into a modular GitHub Actions template. The template is open-source and available on GitHub at https://github.com/victor-lis-bronzo/tag-release-template.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

A Few Tips for Improving Your SEO

Over the years I’ve been tinkering with my blog, I’ve spent quite a bit of time looking into SEO. Just to understand why some pages rank high on Google while others remain invisible.

More from Tuesday 25 August →