/waka-readme

Wakatime Weekly Metrics on your Profile Readme.

Primary LanguagePythonMIT LicenseMIT

waka-readme

Dev Metrics in Readme Build Status

WakaTime weekly metrics on your profile readme.

Project Preview

💬 Forum | GitHub discussions

New to WakaTime?

Nope? Skip to prep work.

WakaTime gives you an idea of the time you spent on coding. This helps you boost your productivity and competitive edge.

  1. Head over to https://wakatime.com/ and create an account.
  2. After logging in get your WakaTime API Key from https://wakatime.com/api-key/.
  3. Install WakaTime plugin in your favorite editor / IDE.
  4. Paste in your API key to start telemetry.

ℹ️ Info | You can read WakaTime help to know more about configurations. Alternatively, you can also fetch data from WakaTime compatible services like Wakapi or Hakatime.

Prep Work

A GitHub repository and a README file is required. We'll be making use of readme in the profile repository*.

  • Save the README file after copy-pasting the following special comments. Your dev-metics will show up in between. waka here can be replaced by any string as long as you set the SECTION_NAME environment variable as per the Tweaks section.

    <!--START_SECTION:waka-->
    <!--END_SECTION:waka-->
    
  • Navigate to your repo's Settings > Secrets and add a new secret named WAKATIME_API_KEY with your API key as it's value.

    Or use the url https://github.com/USERNAME/USERNAME/settings/secrets/actions/new by replacing the USERNAME with your own username. new_secrets_actions

  • Create a new workflow file (waka-readme.yml) inside .github/workflows/ folder of your repository. You can create it from a template using the actions tab of your repository too.

  • Clear any existing contents, add the following lines and save the file.

    name: Waka Readme
    
    on:
      workflow_dispatch: # for manual workflow trigger
      schedule:
        - cron: '0 0 * * *' # runs at every 12AM UTC
    
    jobs:
      update-readme:
        name: WakaReadme DevMetrics
        runs-on: ubuntu-latest
        steps:
          - uses: athul/waka-readme@master
            with:
              WAKATIME_API_KEY: ${{ secrets.WAKATIME_API_KEY }}
              # following flags are required, only if this is not on
              # profile readme, remove the leading `#` to use them
              #GH_TOKEN: ${{ secrets.GH_TOKEN }}
              #REPOSITORY: <gh_username/gh_username>

Tweaks

There are many flags that you can tweak to suit your taste!

Flag Default Options Meaning
API_BASE_URL https://wakatime.com/api https://wakatime.com/api, https://wakapi.dev/api, https://hakatime.mtx-dev.xyz/api Integration with WakaTime compatible services like Wakapi & Hakatime are possible
REPOSITORY <gh_username>/<gh_username> <gh_username>/<repo_name> Waka-readme stats will appear on the provided repository
SECTION_NAME waka any string The generator will look for this section to fill up the readme.
COMMIT_MESSAGE Updated waka-readme graph with new metrics anything else! Messaged used when committing updated stats
SHOW_TITLE false false, true Add title to waka-readme stats blob
BLOCKS ░▒▓█ ░▒▓█, ⣀⣄⣤⣦⣶⣷⣿, -#, you can be creative! Ascii art used to build stats graph
TIME_RANGE last_7_days last_7_days, last_30_days, last_6_months, last_year, all_time String representing a dispensation from which stats are aggregated
SHOW_TIME true false, true Displays the amount of time spent for each language
SHOW_TOTAL false false, true Show total coding time
SHOW_MASKED_TIME false false, true Adds total coding time including unclassified languages (overrides: SHOW_TOTAL)

Example

waka-readme.yml

name: Waka Readme

on:
  workflow_dispatch:
  schedule:
    # Runs at 12am UTC
    - cron: '0 0 * * *'

jobs:
  update-readme:
    name: WakaReadme DevMetrics
    runs-on: ubuntu-latest
    steps:
      - uses: athul/waka-readme@master
        with:
          WAKATIME_API_KEY: ${{ secrets.WAKATIME_API_KEY }}
          SHOW_TITLE: true
          BLOCKS: ->
          TIME_RANGE: all_time
          SHOW_TIME: true
          SHOW_MASKED_TIME: true

README.md

From: 10 July 2020 - To: 06 August 2022

Total Time: 1,464 hrs 54 mins

Python             859 hrs 29 mins >>>>>>>>>>>>>>-----------   54.68 %
Markdown           132 hrs 33 mins >>-----------------------   08.43 %
TeX                103 hrs 52 mins >>-----------------------   06.61 %
HTML               94 hrs 48 mins  >>-----------------------   06.03 %
Nim                64 hrs 31 mins  >------------------------   04.11 %
Other              47 hrs 58 mins  >------------------------   03.05 %

Why only the language stats (and not other data) from the API?

I am a fan of minimal designs and the profile readme is a great way to show off your skills and interests. The WakaTime API, gets us a lot of data about a person's coding activity including the editors and Operating Systems you used and the projects you worked on. Some of these projects maybe secretive and should not be shown out to the public. Using up more data via the Wakatime API will clutter the profile readme and hinder your chances on displaying what you provide value to the community like the pinned Repositories. I believe that Coding Stats is nerdiest of all since you can tell the community that you are exercising these languages or learning a new language, this will also show that you spend some amount of time to learn and exercise your development skills. That's what matters in the end ❤️


*REPOSITORY flag and GH_TOKEN secret are required you're not using profile readme.