Switch from Lambda to GitHub Actions
code
• June 1, 2022
This year I migrated my scheduled bots (like Weatherbot and Weather status) from using AWS Lambda to GitHub Actions.
- Everything in one place. The biggest motivation for the move was to have the code and workflow all in one place. Actions will run on the last commit to the default branch unless otherwise configured. No more committing code to GitHub and then uploading it to AWS.
- Readable workflows. I think writing an Action workflow is far more enjoyable and readable than an AWS CloudFormation template. Similarly, I have found Actions requires fewer resources and configurations than AWS.
-
Helpful bundlers. Since GitHub requires that you commit
node_modules
along with your script, I use @vercel/ncc to bundle the code. I like letting ncc handle that piece. - Secrets! With Actions you can create and reference secrets in your repository. While you can also do this in AWS, I found the process much easier and approachable with Actions, especially when you need to rotate tokens.
- Cron schedules. Like Lambda, Actions offers cron scheduling among its many triggers.
- Step-by-step. Since actions are modularized into steps, an action is singular and plural. I can chain together other actions or run a shell script.
- Workflows to update workflows. I love that you can use Dependabot to keep actions up-to-date.
Actions wins at fast testing and iteration. As soon as I commit code, I can see if my workflow succeeded (or failed) within a minute. All that adds to the delight of building something new.