Skip to content

Commit

Permalink
feat: flags to tweak commit info; bump version
Browse files Browse the repository at this point in the history
- flags are now available to modify commit information
- adds these flags to `dockerfile` & `action.yml`
- fixes a few typos
- improves `Readme.md`
- updates secondary dependencies
- bumps project version

**Related Items**

_Issues_

- Closes #103
- Closes #104
- Closes #125
  • Loading branch information
yozachar committed Jul 18, 2023
1 parent 7d29cf1 commit a3e45eb
Show file tree
Hide file tree
Showing 6 changed files with 259 additions and 114 deletions.
95 changes: 69 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Alternatively, you can also fetch data from WakaTime compatible services like [W

## Prep Work

A GitHub repository and a `README.md` file is required. We'll be making use of readme in the [profile repository][profile_readme]\*.
A GitHub repository and a `README.md` file is required. We'll be making use of readme in the [profile repository][profile_readme].

- Save the `README.md` file after copy-pasting the following special comments. Your dev-metics will show up in between.

Expand All @@ -48,7 +48,7 @@ A GitHub repository and a `README.md` file is required. We'll be making use of r
- If you're not using [profile repository][profile_readme], add another secret _named_ `GH_TOKEN` and insert your [GitHub token][gh_access_token]\* in place of _value_.

- 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.
- Clear any existing contents, add the following lines and save the `waka-readme.yml` workflow file.

```yml
name: Waka Readme
Expand All @@ -72,25 +72,47 @@ A GitHub repository and a `README.md` file is required. We'll be making use of r
#REPOSITORY: <gh_username/gh_username>
```

Refer [#Example](#example) section for a full blown workflow file.

## 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][wakapi] & [Hakatime][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 alphanumeric string | The generator will look for this section to fill up the readme. |
| `COMMIT_MESSAGE` | `Updated waka-readme graph with new metrics` | Any string | Messaged used when committing updated stats |
| `CODE_LANG` | `txt` | `python` `ruby` `json` , you can use other languages also | Language syntax to format the generated text, to get colored text. |
| `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`) |
| `LANG_COUNT` | `5` | Any reasonable number | Number of languages to be displayed |
| `STOP_AT_OTHER` | `false` | `false`, `true` | Stop when language marked as `Other` is retrieved (overrides: `LANG_COUNT`) |
There are many flags that you can tweak as you wish!

### Meta Tweaks

| Environment flag | Options (`Default`, `Other`, ...) | Description |
| ---------------- | ---------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------- |
| `API_BASE_URL` | `https://wakatime.com/api`, `https://wakapi.dev/api`, `https://hakatime.mtx-dev.xyz/api` | Use WakaTime compatible services like [Wakapi][wakapi] & [Hakatime][hakatime] |
| `REPOSITORY` | `<gh_username>/<gh_username>`, `<gh_username>/<repo_name>` | Waka-readme stats will appear on the provided repository |

### Content Tweaks

| Environment flag | Options (`Default`, `Other`, ...) | Description |
| ------------------ | ----------------------------------------------------------------------- | --------------------------------------------------------------------------------- |
| `SHOW_TITLE` | `false`, `true` | Add title to waka-readme stats blob |
| `SECTION_NAME` | `waka`, any alphanumeric string | The generator will look for section name to fill up the readme. |
| `BLOCKS` | `░▒▓█`, `⣀⣄⣤⣦⣶⣷⣿`, `-#`, `=>`, you can be creative | Ascii art used to build stats graph |
| `CODE_LANG` | `txt`, `python` `ruby` `json` , you can use other languages also | Language syntax based highlighted text |
| `TIME_RANGE` | `last_7_days`, `last_30_days`, `last_6_months`, `last_year`, `all_time` | String representing a dispensation from which stats are aggregated |
| `LANG_COUNT` | `5`, any plausible number | Number of languages to be displayed |
| `SHOW_TIME` | `true`, `false` | Displays the amount of time spent for each language |
| `SHOW_TOTAL` | `false`, `true` | Show total coding time |
| `SHOW_MASKED_TIME` | `false`, `true` | Adds total coding time including unclassified languages (overrides: `SHOW_TOTAL`) |
| `STOP_AT_OTHER` | `false`, `true` | Stop when language marked as `Other` is retrieved (overrides: `LANG_COUNT`) |

### Commit Tweaks

| Environment flag | Options (`Default`, `Other`, ...) |
| ----------------- | -------------------------------------------------------------------- |
| `COMMIT_MESSAGE` | `Updated waka-readme graph with new metrics`, any reasonable message |
| `TARGET_BRANCH` | `NOT_SET`, target branch name |
| `TARGET_PATH` | `NOT_SET`, `/path/to/target/file` |
| `COMMITTER_NAME` | `NOT_SET`, committer name |
| `COMMITTER_EMAIL` | `NOT_SET`, committer email |
| `AUTHOR_NAME` | `NOT_SET`, author name |
| `AUTHOR_EMAIL` | `NOT_SET`, author email |

All of these flags are _optional_.

# Example

Expand All @@ -112,15 +134,40 @@ jobs:
steps:
- uses: athul/waka-readme@master
with:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
WAKATIME_API_KEY: ${{ secrets.WAKATIME_API_KEY }}
# meta
API_BASE_URL: https://wakatime.com/api
REPOSITORY: athul/athul
# content
SHOW_TITLE: true
SECTION_NAME: waka
BLOCKS: ->
TIME_RANGE: all_time
SHOW_TIME: true
SHOW_MASKED_TIME: true
CODE_LANG: all_time
TIME_RANGE: true
LANG_COUNT: 10
SHOW_TIME: true
SHOW_TOTAL: true
SHOW_MASKED_TIME: false
STOP_AT_OTHER: true
# commit
COMMIT_MESSAGE: Updated waka-readme graph with new metrics
TARGET_BRANCH: master
TARGET_PATH: README.md
COMMITTER_NAME: GitHubActionBot
COMMITTER_EMAIL: [email protected]
AUTHOR_NAME: Athul
AUTHOR_EMAIL: [email protected]
# you can populate email-id with secretes instead
```

> Note:
>
> - Flags `REPOSITORY` and `GH_TOKEN` are required, ONLY if you're NOT using [profile readme][profile_readme].
> - `WAKATIME_API_KEY` is a required secret.
> - Every other environment variables is optional.
> - The above example does not show proper default values, refer [#Tweaks](#tweaks) for the same.
**`README.md`**

```md
Expand All @@ -140,10 +187,6 @@ Other 47 hrs 58 mins >------------------------ 03.05 %

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 :heart:

---

<sup>\*</sup>`REPOSITORY` flag and `GH_TOKEN` secret are required you're not using profile readme.

[//]: #(Links)
[wakapi]: https://wakapi.dev
[hakatime]: https://github.com/mujx/hakatime
Expand Down
52 changes: 33 additions & 19 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,84 +1,98 @@
name: "Waka - Readme"
author: Athul Cyriac Ajay
description: "Add a Wakatime Coding Activity graph in your Readme"
author: "Athul Cyriac Ajay"
description: "WakaTime coding activity graph in your profile readme"

inputs:
GH_TOKEN:
description: "GitHub access token with Repo scope"
default: ${{ github.token }}
required: true

WAKATIME_API_KEY:
description: "Your Wakatime/Wakapi/Hakatime API Key"
required: true

# meta tweaks
API_BASE_URL:
description: "Alternative API base URL when using a third-party WakaTime-ish backend"
default: "https://wakatime.com/api"
required: false

REPOSITORY:
description: "Your GitHub repository"
default: ${{ github.repository }}
required: false

COMMIT_MESSAGE:
description: "Add a commit message of your choice"
default: "Updated waka-readme graph with new metrics"
required: false

# content tweaks

SHOW_TITLE:
description: "Displays the week number and days in Readme as title"
default: "false"
required: false

SECTION_NAME:
description: "Section name for data to appear in readme"
required: false
default: "waka"

BLOCKS:
description: "Add the progress blocks of your choice"
default: "░▒▓█"
required: false

CODE_LANG:
description: "Add syntax formatter for generated code"
default: "txt"
required: false

TIME_RANGE:
description: "Time range of the queried statistics"
default: "last_7_days"
required: false

LANG_COUNT:
description: "Maximum number of languages to be shown"
default: "5"
required: false

SHOW_TIME:
description: "Displays the amount of time spent for each language"
default: "true"
required: false

SHOW_TOTAL:
description: "Displays total coding time"
default: "false"
required: false

SHOW_MASKED_TIME:
description: "Displays total coding time including unclassified languages"
default: "false"
required: false

STOP_AT_OTHER:
description: "Stop data retrieval when language marked 'Other' is reached"
default: "false"
required: false

# commit tweaks
COMMIT_MESSAGE:
description: "Add a commit message of your choice"
default: "Updated waka-readme graph with new metrics"
required: false
TARGET_BRANCH:
description: "Target branch"
default: "NOT_SET"
required: false
TARGET_PATH:
description: "Target file path"
default: "NOT_SET"
required: false
COMMITTER_NAME:
description: "Committer name"
default: "NOT_SET"
required: false
COMMITTER_EMAIL:
description: "Committer email"
default: "NOT_SET"
required: false
AUTHOR_NAME:
description: "Author name"
default: "NOT_SET"
required: false
AUTHOR_EMAIL:
description: "Author email"
default: "NOT_SET"
required: false

runs:
using: "docker"
image: "dockerfile"
Expand Down
19 changes: 15 additions & 4 deletions dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,29 @@ FROM docker.io/python:3-slim

ENV INPUT_GH_TOKEN \
INPUT_WAKATIME_API_KEY \
# meta
INPUT_API_BASE_URL \
INPUT_REPOSITORY \
INPUT_COMMIT_MESSAGE \
# content
INPUT_SHOW_TITLE \
INPUT_SECTION_NAME \
INPUT_BLOCKS \
INPUT_CODE_LANG \
INPUT_TIME_RANGE \
INPUT_LANG_COUNT \
INPUT_SHOW_TIME \
INPUT_SHOW_TOTAL \
INPUT_TIME_RANGE \
INPUT_SHOW_MASKED_TIME \
INPUT_LANG_COUNT \
INPUT_STOP_AT_OTHER
INPUT_STOP_AT_OTHER \
# commit
INPUT_COMMIT_MESSAGE \
INPUT_TARGET_BRANCH \
INPUT_TARGET_PATH \
INPUT_COMMITTER_NAME \
INPUT_COMMITTER_EMAIL \
INPUT_AUTHOR_NAME \
INPUT_AUTHOR_EMAIL


ENV PATH="${PATH}:/root/.local/bin" \
# python
Expand Down
Loading

0 comments on commit a3e45eb

Please sign in to comment.