How to automate data collection and app deployment with GitHub Actions.
GitHub Actions is a tool that allows you to implement automations within your repositories.
You can create workflows to automate data collection pipelines, app deployment, and even order a pizza for yourself!
There are many things you can do with GitHub Actions, and the best part - it’s free* for public repositories!
*GitHub allows free use of 2,000 minutes of workflow computing time per month. To put that in perspective, I use about 240 minutes per month for the repository I will be discussing in this post, so 2,000 minutes is likely more than enough for most projects.
GitHub Actions workflows are YAML files that define the automated processes to occur when a particular event is triggered in your repository. The workflows are stored within a
.github/workflows directory, such as this one: .
You are able to create multiple workflows within your repository that can perform different sets of actions, or you can just use one. Note: I will just be discussing how to create one workflow in this post.
In this tutorial, I’ll be sharing the GitHub Actions workflow that I created for my U.S. gas prices app to automate the data collection and app deployment pipelines.
The first section of the workflow defines the event that triggers the workflow to run.
For my app, the gas price data I use is updated once per week by the EIA “around 5PM EST every Monday” according to their documentation. So, in order to automate the data collection for my app, I needed to kickoff the workflow every Monday night a little after 5PM EST so that it could collect the latest data. I decided to set the time to 7:30PM EST to err on the side of caution in case EIA was late updating their data.
The workflow requires the date/time to be in cron format, so I converted “7:30PM EST every Monday” to a cron date/time of ‘30 23 * * 1’ by using this cron time converter.
In addition to scheduling a time for the workflow to run, I also set the workflow to kickoff whenever I made a push to the main branch with
push: branches: main. This is useful for whenever you need to make an update to your process but don’t want to wait until the workflow is scheduled to run.
on: schedule: - cron: '30 23 * * 1' push: branches: main
Note: when your GitHub Actions workflow kicks off, you can track it’s progress live by clicking the Actions tab in your repository.