Auto-populate your Github readme with data fetched from a remote notion database.

Auto-populate your Github readme with data fetched from a remote notion database.

Github actions enable you to leverage the powerful world of open source software and utilize its functionality in your CI workflow.

Hello everyone. This article will share how I managed to auto-populate a Github readme learned section using data fetched from a remote notion database using a GitHub action that I created using Typescript.



In Repository File

1. Add the following content to your

## What I have learned so far


2. Configure the workflow

name: 'Github Readme Updater'
    - cron: '0 0 * * *' # Runs Every Day
    name: 'Update learn section'
    runs-on: ubuntu-latest
      - name: 'Fetching Repository Contents'
        uses: actions/checkout@main
      - name: 'Learn Section Updater'
        uses: 'devorein/github-readme-learn-section-notion@master'
          database_id: '6626c1ebc5a44db78e3f2fe285171ab7'
          token_v2: ${{ secrets.NOTION_TOKEN_V2 }} # Required only if your database is private

TIP: You can test out using this template that I've created just for this purpose.

In your notion account

1. Create a full-page database

Notion Full Page Database

NOTE: Your database must maintain the following structure/schema

Notion Table Schema Options

2. Get the id of the database

Notion Full Page Database Id

3. Add it in the workflow file

  database_id: '6626c1ebc5a44db78e3f2fe285171ab7'

Follow the rest of the steps only if your database is not public, if its public you don't need to set the token_v2

To make your database public

  1. Navigate to the database in your notion account
  2. Click on Share at the top right corner
  3. Click on the Share to Web button.

1. Get your notion token_v2

NOTE: By no means should you share or expose your notion token_v2. If you feel like you've done so accidentally, immediately log out from that account in all of your devices.

Follow the steps below to obtain your token_v2:

  1. Open up the dev tools of your preferred browser.
  2. Go to the Application > Cookies section.
  3. There you'll find a token_v2 cookie.

NOTE: Its highly recommended to store your token_v2 as a github secret rather than pasting it in your workflow file.

2. Create a github secret to store token_v2

  1. navigate to the url<USERNAME>/<REPO-NAME>/settings/secrets/actions
  2. Click on New repository secret
  3. You can name your secret as anything you want
  4. Paste the token_v2 value in the Value textarea
  5. Use the secret in your workflow file
  token_v2: ${{ secrets.NOTION_TOKEN_V2 }} # The secret was named NOTION_TOKEN_V2


If you follow all the steps properly your readme should look something like this.

Github Readme Learn Section

Hope this was helpful to you. That's all from me for now.

The code for the Github action is here. Feel free to submit a pull request or open a new issue, contributions are highly appreciated and more than welcome. Thank you for reading.