Fast GitHub Actions deployments for emergencies
Posted on under Engineering
We use Sapper and Svelte for the Pabio's old website, and we have a pretty comprehensive CI/CD build process. The process includes running unit tests, Cypress end-to-end tests, Lighthouse audits, Semantic Release versioning, and finally exporting a static version of the site which is then published.
This, however, means that the entire CI flow from commit push to deployment takes between 3 and 4.5 minutes, which might be too late for emergency deployments for important bug fixes. For this, we made a “fast” deployment process that skips all tests and just exports, purges, and deploys. This takes less than a minute, but of course is dangerous and should only be used in exceptional circumstances (luckily, we haven’t had the need for this yet).
For the Fast Deploy GitHub Actions workflow, we make sure that the last commit message includes the text
[fast], just like you’d check for the text
[skip ci] to skip the process altogether. This is a separate workflow that only runs when the
[fast] flag is present in a commit, so it’s skipped in almost all pushes.
In this workflow, we only checkout the repository, install Node.js and then the dependencies, and build the static site. Then, we push it to the
gh-pages branch and deploy that branch on our CDN, while force-purging its cache to make sure all users will see the most recent version.
Of course, this is not recommended for day-to-day use and only for those specific emergencies when you need to push your code really quickly.