Skip to content

Commit

Permalink
Merge pull request #135 from joe733/workshop
Browse files Browse the repository at this point in the history
feat: flags to tweak commit info; bump version
  • Loading branch information
yozachar authored Jul 19, 2023
2 parents cefd952 + a3e45eb commit 78ac94e
Show file tree
Hide file tree
Showing 7 changed files with 272 additions and 126 deletions.
25 changes: 13 additions & 12 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
# The MIT License (MIT)
MIT License

Copyright (c) 2020 ATHUL CYRIAC AJAY

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
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 78ac94e

Please sign in to comment.