codeburst

Bursts of code to power through your day. Web Development articles, tutorials, and news.

Follow publication

Storing Weather Data Daily using GitHub Actions

Changhui Xu
codeburst
Published in
7 min readOct 7, 2019

--

With GitHub Actions (link), we can easily modify a template workflow to define an automated software development life cycle. In this blog post, I will show you how to use GitHub Actions to run a daily job and save day-to-day weather conditions into a GitHub repository. We will touch base on the environment variables and GitHub secrets, as well as GitHub personal access tokens. Well, I am not going to pretend to be an expert on GitHub Actions. It took me sometime to read the documentation and I only learned several things by trail and error. 😃

We will begin with an empty GitHub repository and a starter workflow template, then get our feet wet in the shell scripts. Once we have a feel for the playground, then we can query weather conditions from an API endpoint and save the HTTP response data into a JSON file. After that, we commit the newly generated files to the same GitHub repository. Finally, we schedule the workflow to run every day, so that we will have a collection of historical weather data which can be consumed by other applications.

The full project is located in this GitHub repository.

Background of this project

In my last blog post, we created a command line interface (CLI) app with Node.js to check current weather conditions and weather forecasts. However, I occasionally want to compare today’s temperature with the temperatures in the past several days, so that I know what to put on my son and daughter. Surprisingly, most of the weather websites/apps or TV channels don’t tell us weather conditions in the past week or so. Therefore, I decided to save the historical weather data on my own.

Besides the practical use case, this project is driven by my desire to learn GitHub Actions, which is a free service for public GitHub repositories and is a natural approach for continuous integration (CI) and continuous deployment (CD). By working on this small project, I can master some basics on customizing the actions, similar to what we usually do with other CI/CD providers, such as Travis-CI, CircleCI, AppVeyor, Netlify, and so on.

The final result is a small web app (link) to visualize the temperatures in the past, which are from the data that GitHub collects for me every morning.

--

--

Published in codeburst

Bursts of code to power through your day. Web Development articles, tutorials, and news.

Written by Changhui Xu

Lead Application Developer. MBA. I write blogs about .NET, Angular, JavaScript/TypeScript, Docker, AWS, DDD, and many others.

No responses yet

Write a response