Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/thanhhaudev/github-stats
Show impressive metrics on your GitHub profile π π
https://github.com/thanhhaudev/github-stats
awsome-profile github-api github-profile-readme markdown metrics profile-generator profile-readme readme time-tracker wakatime wakatime-api wakatime-plugin wakatime-stats
Last synced: 5 days ago
JSON representation
Show impressive metrics on your GitHub profile π π
- Host: GitHub
- URL: https://github.com/thanhhaudev/github-stats
- Owner: thanhhaudev
- Created: 2024-08-08T06:27:32.000Z (3 months ago)
- Default Branch: master
- Last Pushed: 2024-11-07T06:48:32.000Z (7 days ago)
- Last Synced: 2024-11-07T07:33:06.333Z (7 days ago)
- Topics: awsome-profile, github-api, github-profile-readme, markdown, metrics, profile-generator, profile-readme, readme, time-tracker, wakatime, wakatime-api, wakatime-plugin, wakatime-stats
- Language: Go
- Homepage:
- Size: 82 KB
- Stars: 12
- Watchers: 2
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# GitHub README.md Metrics π
This GitHub Action collects your GitHub data and coding activity from WakaTime. It updates a part of your README.md file with cool metrics from this data and then commits and pushes the changes to your repository.
## Prerequisites
1. **Special Repository**: To make this Action work, you need a **special repository** with the same name as your GitHub username (e.g., `username/username`). This is a special repository on GitHub where the README will show up on your profile.
2. **Update the Markdown File**: You need to add two special comments to your Markdown (.md) file. These comments will be used to update the file with the metrics. You can add these comments anywhere in the file, but it's recommended to add them at the end of the file.
```markdown
```The Action will replace everything between these two comments with the metrics. You can also specify a section name in the `SECTION_NAME` environment variable.
3. **GitHub Access Token**: To get commit information, you need a GitHub Access Token with `repo` and `user` permissions, available [here](https://github.com/settings/tokens).
>Although giving `repo` access might seem **risky**, this Action only accesses commit timestamps and lines of code added or deleted in the repositories you contributed to, which is completely safe.4. **WakaTime API Key (Optional)**: If you want to use the `WAKATIME_SPENT_TIME` metric, you will need a WakaTime API Key. You can get this from your [WakaTime Account Settings](https://wakatime.com/settings/api-key).
5. **Store Access Keys in Secrets**: You need to store the WakaTime API Key and GitHub Access Token in your repository secrets. You can find this option in the **Settings** of your GitHub repository. Make sure to save them under the following names:
+ **WAKATIME_API_KEY**: Your WakaTime API Key.
+ **GH_TOKEN**: Your GitHub Access Token.## Usage
### Environment Variables
| Name | Description | Required | Default |
|------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------|---------------------------|
| `GITHUB_TOKEN` | The GitHub token to authenticate API requests. | Yes | - |
| `SHOW_METRICS` | The metrics to show in the `README.md` file. | Yes | - |
| `WAKATIME_API_KEY` | The WakaTime API key to fetch coding activity statistics. | No | - |
| `WAKATIME_RANGE` | The range for WakaTime statistics (e.g., `last_7_days`, `last_30_days`, `last_6_months`, `last_year`, `all_time`). | No | last_7_days |
| `WAKATIME_DATA` | The data to show from WakaTime statistics. | If `WAKATIME_API_KEY` is provided | - |
| `TIME_ZONE` | The timezone to use for statistics. | No | UTC |
| `TIME_LAYOUT` | The layout of the time to show in the last update time. | No | 2006-01-02 15:04:05 -0700 |
| `SHOW_LAST_UPDATE` | Whether to show the last update time in the `README.md` file. | No | - |
| `ONLY_MAIN_BRANCH` | Whether to fetch data only from the main branch. If you donβt set this, it will search for commits in all branches of the repository to count the number of commits, which might take more time. | No | - |
| `COMMIT_MESSAGE` | The commit message to use when updating the `README.md`. | No | π Update README.md |
| `COMMIT_USER_NAME` | The name to use for the commit. | No | GitHub Action |
| `COMMIT_USER_EMAIL` | The email to use for the commit. | No | [email protected] |
| `SECTION_NAME` | The section name in the `README.md` to update. | No | readme-stats |
| `HIDE_REPO_INFO` | Whether to hide the repository information in action logs. | No | - |
| `PROGRESS_BAR_VERSION` | The version of the progress bar to use. | No | 1 |
| `EXCLUDE_FORK_REPOS` | Whether to exclude fork repositories from the metrics. | No | - |
| `LANGUAGES_AND_TOOLS` | The languages and tools that you used in your repositories. | No | - |### Metrics
The `SHOW_METRICS` environment variable is used to specify the metrics to show in the `README.md` file. You can choose from the following metrics:**COMMIT_TIME_OF_DAY**: The time of day you make commits.
**π I'm An Afternoon Warrior π₯·π»**
```
π Morning 136 commits βββββββββββββββββββββββββ 29.18%
π Daytime 265 commits βββββββββββββββββββββββββ 56.87%
π Evening 1 commit βββββββββββββββββββββββββ 00.21%
π Night 64 commits βββββββββββββββββββββββββ 13.73%
```**COMMIT_DAYS_OF_WEEK**: The days of the week you make commits.
**π I'm Most Productive on Sundays**
```
Sunday 112 commits βββββββββββββββββββββββββ 24.03%
Monday 57 commits βββββββββββββββββββββββββ 12.23%
Tuesday 58 commits βββββββββββββββββββββββββ 12.45%
Wednesday 73 commits βββββββββββββββββββββββββ 15.67%
Thursday 94 commits βββββββββββββββββββββββββ 20.17%
Friday 31 commits βββββββββββββββββββββββββ 06.65%
Saturday 41 commits βββββββββββββββββββββββββ 08.80%
```**LANGUAGE_PER_REPO**: The languages you use in each repository.
**π₯ I Mostly Code in Go**
```
Go 6 repos βββββββββββββββββββββββββ 85.71%
TypeScript 1 repo βββββββββββββββββββββββββ 14.29%
```**LANGUAGES_AND_TOOLS**: The languages and tools you used on your projects.
**π¬ Languages & Tools**
![JavaScript](https://img.shields.io/badge/JavaScript-20.0%25-f1e05a?&logo=JavaScript&labelColor=151b23)
![Python](https://img.shields.io/badge/Python-13.0%25-3572A5?&logo=Python&labelColor=151b23)
![Java](https://img.shields.io/badge/Java-12.0%25-b07219?&logo=Java&labelColor=151b23)
![C#](https://img.shields.io/badge/C%23-9.4%25-178600?&logo=CSharp&labelColor=151b23)
![PHP](https://img.shields.io/badge/PHP-7.8%25-4F5D95?&logo=PHP&labelColor=151b23)
![C++](https://img.shields.io/badge/C++-7.0%25-00599C?&logo=Cplusplus&labelColor=151b23)
![TypeScript](https://img.shields.io/badge/TypeScript-6.3%25-3178C6?&logo=TypeScript&labelColor=151b23)
![Ruby](https://img.shields.io/badge/Ruby-3.1%25-701516?&logo=Ruby&labelColor=151b23)
![Swift](https://img.shields.io/badge/Swift-2.6%25-FA7343?&logo=Swift&labelColor=151b23)
![Go](https://img.shields.io/badge/Go-2.8%25-00ADD8?&logo=Go&labelColor=151b23)**WAKATIME_SPENT_TIME**: The time you spent coding on WakaTime.
Use the `WAKATIME_DATA` environment variable to specify the data to show.
+ **EDITORS**: The editors you use.
```
π Editors:
PhpStorm 42 hrs 14 mins βββββββββββββββββββββββββ 93.02%
GoLand 3 hrs 10 mins βββββββββββββββββββββββββ 06.98%
```
+ **LANGUAGES**: The languages you code in.
```
π¬ Languages:
Go 22 hrs 19 mins βββββββββββββββββββββββββ 49.16%
JavaScript 14 hrs 41 mins βββββββββββββββββββββββββ 32.34%
Python 1 hr 53 mins βββββββββββββββββββββββββ 04.18%
Java 1 hr 27 mins βββββββββββββββββββββββββ 03.20%
C++ 1 hr 15 mins βββββββββββββββββββββββββ 02.78%
Ruby 1 hr 12 mins βββββββββββββββββββββββββ 02.66%
PHP 52 mins βββββββββββββββββββββββββ 01.92%
TypeScript 43 mins βββββββββββββββββββββββββ 01.58%
Swift 22 mins βββββββββββββββββββββββββ 00.81%
Rust 15 mins βββββββββββββββββββββββββ 00.56%
Others 16 mins βββββββββββββββββββββββββ 00.80%
```
+ **PROJECTS**: The projects you work on.
```
π¦ Projects:
Project A 6 hrs 47 mins βββββββββββββββββββββββββ 77.43%
Project B 1 hr 35 mins βββββββββββββββββββββββββ 18.07%
Project C 23 mins βββββββββββββββββββββββββ 4.49%
```
+ **OPERATING_SYSTEMS**: The operating systems you use.
```
π» Operating Systems:
Windows 42 hrs 14 mins βββββββββββββββββββββββββ 70.00%
Mac 12 hrs 10 mins βββββββββββββββββββββββββ 20.00%
Linux 6 hrs 3 mins βββββββββββββββββββββββββ 10.00%
```You can use the `WAKATIME_RANGE` environment variable to set the time range for WakaTime statistics. Each value will show a specific label as follows:
+ `last_7_days`: π This Week I Spent My Time On
+ `last_30_days`: π This Month I Spent My Time On
+ `last_6_months`: π In the Last 6 Months I Spent My Time On
+ `last_year`: π This Year I Spent My Time On
+ `all_time`: π All The Time I Spent On**Note**: If you don't provide the `WAKATIME_API_KEY`, the `WAKATIME_SPENT_TIME` metric will not be shown.
### Progress Bar Versions
You can use the `PROGRESS_BAR_VERSION` environment variable to specify the version of the progress bar to use. The available versions are:
+ `1`: **Default Progress Bar**: Uses the default progress bar style.
```
βββββββββββββββββββββββββ
```
+ `2` **Square Symbol Progress Bar**: Uses the square symbol for the progress bar. This version also shows the half block (the remaining percentage is not enough to fill a whole block) for the progress bar.
```
π©π©π©π©π©π©π©π©π¨β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬
```### Example Workflow
```yaml
name: Update README.mdon:
schedule:
- cron: '0 0 * * *' # Runs every day at midnight
workflow_dispatch:
jobs:
update-readme:
name: Update README.md
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Run GitHub Stats Action
uses: thanhhaudev/github-stats@master
env:
BRANCH_NAME: ${{ github.ref_name }}
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} # GitHub token, required
WAKATIME_API_KEY: ${{ secrets.WAKATIME_API_KEY }}
WAKATIME_DATA: "EDITORS,LANGUAGES,PROJECTS,OPERATING_SYSTEMS" # show data, separated by comma
SHOW_METRICS: "COMMIT_TIME_OF_DAY,LANGUAGE_PER_REPO,COMMIT_DAYS_OF_WEEK,WAKATIME_SPENT_TIME" # show metrics, separated by comma
SHOW_LAST_UPDATE: "true" # show last update time
ONLY_MAIN_BRANCH: "true" # only fetch data from the main branch
```---
> This project is inspired by [waka-readme-stats](https://github.com/anmol098/waka-readme-stats), which is a similar project that uses GitHub Actions to update your README with awesome metrics.