Member-only story
Automating Twilio Function Deployments using the Twilio CLI and Github Actions
How to skip the endless Googling and get right to the fun parts
It’s easy to get swept into a great HackerNews or Medium write up and believe that frontend development is a walk in the park. In reality, it’s more like a marathon in a thunderstorm: into the wind, non-stop and exhausting — but ultimately gratifying. Streamlining Twilio Functions using CLI and Github is a great example of this experience, and I’ve documented my learnings to help others on this journey.
But first, a little introduction.
Deploying Twilio Functions
I recently wrote an article narrating the journey of migrating from Twilio Functions Classic over to CLI but even if you’re using the latest version with the command-line interface, deployments can still be suboptimal.
Once configured, deploying to an environment can be as simple as npm run deploy
. It’s really very easy. The problem that arises — especially when working in teams — is knowing who last deployed what and to where.
twilio serverless:deploy --env=./build/.constants.staging --environment=staging --profile=ta-env-staging --override-existing-project
When using pretty standard Git workflows, it’s usually simple to see what has changed, and utilising version control made our development process at TripActions dramatically more transparent. Just being able to make pull requests and have branches was super useful.
But on its own, Git won’t tell you what is deployed to each environment.
Enter GitHub Actions
GitHub Actions are somewhat new to the CI/CD scene, arriving in late 2019. Now there is a rich environment of apps you can draw on, offering all kinds of functionality from linting and testing code, notifications on Slack to deduping Lokalise key value pairs.
GitHub actions by default are open for all to see, easy to understand and inherently versioned (being in the repo alongside the code they work with). They can be as simple or as complicated as you need them to be, automating away mundane tasks that need to occur at review time (though…