Willem Hoek

Never forget a birthday again with GitHub Actions and Python

May 24, 2020


Pierre-Auguste Renoir, Luncheon of the Boating Party, 1881

Birthday Reminder

After forgetting yet another birthday, I decided to set up a simple daily email reminder system. It sends me an email every day of all the birthdays coming up in the next few days.

The automation is done using GitHub Actions. It consists of a small Python program and the emails are send using Sendgrid’s API. Due to the low volumes, all the services used - are on FREE plans.

Since setting it up, I have added some forex and stock price information into the daily mail. The code is included in the GitHub repository but can be commented out if not used.

Tools and API’s used

Optional

GitHub Repository

https://github.com/whoek/birthday-reminder

Files used:

Test on your local machine first

def main():
    html_content = \
#       get_forex_html() + \
#       get_stock_html() + \
        get_birthday_html()

Deploy on Github

# Send daily emails - time in UTC (GMT)
name: The Daily Mail
on:
  schedule:
  - cron:  '0 6 * * *'
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - name: Set up Python 3.7
      uses: actions/setup-python@v2
      with:
        python-version: 3.7
    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip
        pip install environs requests sendgrid
    - name: Send email
      run:  python ./daily_mail.py

Total runtime on GitHub is about 30 seconds. On the GitHub free plan, you have 2,000 Actions minutes/month available. So no problem there.

Birthdays

Maintaining the birthday file

I used standard csv file format rather than yaml, json or any other. This is so that I can maintain the list easily on my local machine using Excel. It also displays nicely on GitHub.

Sample file

birthday,age,name,note
2020-06-21,once,Father's Day,Ireland
2021-06-20,once,Father's Day,Ireland
2022-06-19,once,Father's Day,Ireland
2020-05-26,45,Adrian Bruce,birthday
1964-05-27,0,Alexander MacDonald,birthday

Similar Posts on this website

How-to Import an Excel file into SQLite and back to Excel again

Solving the Jane Street puzzle of December 2022

Why I created Scrumdog - a program to download Jira Issues to a local database

Jane Street puzzle Feb 2021 SOLVED! OCaml to the rescue

Solving the Jane Street puzzle of Dec 2020 - Backtracking with OCaml

Automate your Jira reporting with Python and Excel