GitHub Action - Use GitHub Gists as a Todo List

September 04, 2020

Want to use GitHub gists as a todo list? ☑️ Introducing gist-todo-list-action! Be sure to check the README for more info on how to use it. I will soon write a blog post how I created the action.

This is my submission for GitHub Hackathon!

Update:

GitHub declared everyone as a winner 🎉🥳 and I received this nice glass and a pack of stickers! Here’s the winner list. My submission is on line 159 😉.

GitHub Hackathon Glass GitHub Hackathon Glass

GitHub Hackathon Stickers Pack GitHub Hackathon Stickers Pack

The following text is taken from the project readme.

Features

Before

Create a Todo List in a GitHub Gist (following the task list syntax) and create a list, and check the tasks you have done off during the day.

before todo

After

After midnight your done tasks will be transferred to the done list. In this way you will have a history of your list!

Todo Done
after todo done

Usage

  • First create two gists from https://gist.github.com, namely todo and done.

  • Add file todo.md and done.md to them respectively. The file content should be a single header # Todo and # Done respectively.

  • Generate a new personal access token with gist scope from here: https://github.com/settings/tokens/new.

  • Fork this repository. Note that if you want to use GitHub Action from market place, you don’t need to fork this repository. See this for more instruction.

  • Add the gist IDs as TODO_GIST, DONE_GIST and the personal access token as

GH_TOKEN to your repository secrets: https://github.com/<your_username>/<repository_name>/settings/secrets. It will look something like this:

secrets.jpg

Gist ID is the part of the URL after your username. For example the gist ID

of this gist https://gist.github.com/ayan-b/1b44e52eifj09bc75c914f6fedf95304 is 1b44e52eifj09bc75c914f6fedf95304.

  • Now you have your todo list using GitHub gist!

  • Optional: Change the time of cron job in the workflow file according to your time zone so that the todo and done list update exactly at midnight (and not at UTC midnight)!

    Here’s one for IST time zone (UTC +5:30). Note the use of TIME_ZONE environment variable and the change in cron job.

name: Update Todo List IST

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]
  schedule:
    - cron: "30 5 * * *"  # 0 + time zone difference time

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
    - name: Set up Python 3.8
      uses: actions/setup-python@v1
      with:
        python-version: 3.8
    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip
        pip install -r requirements.txt
    - name: Lint with flake8
      run: |
        pip install flake8
        # stop the build if there are Python syntax errors or undefined names
        flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
        # exit-zero treats all errors as warnings.
        flake8 . --count --exit-zero --max-complexity=10 --max-line-length=79 --statistics
    - name: Update todo list
      run: |
        python3 construct_todo.py
      env:
        GH_TOKEN: ${{ secrets.GH_TOKEN }}
        TODO_GIST: ${{ secrets.TODO_GIST }}
        DONE_GIST: ${{ secrets.DONE_GIST }}
        TIME_ZONE: "Asia/Kolkata" # IST

Note that you can use docker as well in the last step (Update todo list) as done in the update-list.yml file. But it will be slower. You can also omit the Lint with flake8 step.

Using with GitHub action

If you want to use GitHub action, your workflow yaml file will look something like this (be sure to change the version to the latest one):

name: Update Todo List IST

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]
  schedule:
    - cron: "30 5 * * *"  # 0 + time zone difference time

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - name: Todo List using GitHub Gist
      uses: ayan-b/gist-todo-list-action@0.1.0
      env:
        GH_TOKEN: ${{ secrets.GH_TOKEN }}
        TODO_GIST: ${{ secrets.TODO_GIST }}
        DONE_GIST: ${{ secrets.DONE_GIST }}
        TIME_ZONE: "Asia/Kolkata" # IST

Profile picture

Written by Ayan Banerjee who is a Software Developer. You should follow them on Twitter

© 2018 - 2022, Built with Gatsby