Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8ac60ed14f | ||
|
|
9ea8300262 | ||
|
|
702a9a9e8e | ||
|
|
c469bfb723 | ||
|
|
6a5ebb1ab0 | ||
|
|
a37900c521 | ||
|
|
8e15ddefda | ||
|
|
64fb92311d | ||
|
|
66fb6bbc52 | ||
|
|
30417a50d4 | ||
|
|
cb9b2232a8 |
24
.github/workflows/main.yml
vendored
24
.github/workflows/main.yml
vendored
@@ -1,24 +0,0 @@
|
|||||||
# This is a basic workflow to help you get started with Actions
|
|
||||||
|
|
||||||
name: Waka Readme
|
|
||||||
|
|
||||||
# Controls when the action will run. Triggers the workflow on push or pull request
|
|
||||||
# events but only for the master branch
|
|
||||||
on:
|
|
||||||
schedule:
|
|
||||||
# Runs at 12am UTC
|
|
||||||
- cron: '0 0 * * *'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: Update Readme
|
|
||||||
uses: athul/waka-readme@master
|
|
||||||
with:
|
|
||||||
WAKATIME_API_KEY: ${{ secrets.WAKATIME_API_KEY }}
|
|
||||||
|
|
||||||
@@ -2,6 +2,7 @@ FROM python:latest
|
|||||||
|
|
||||||
# Install dependencies.
|
# Install dependencies.
|
||||||
ADD requirements.txt /requirements.txt
|
ADD requirements.txt /requirements.txt
|
||||||
|
ADD main.py /main.py
|
||||||
RUN pip install -r requirements.txt
|
RUN pip install -r requirements.txt
|
||||||
|
|
||||||
CMD python main.py
|
CMD ["python", "/main.py"]
|
||||||
73
README.md
73
README.md
@@ -1,6 +1,7 @@
|
|||||||
# Dev Metrics in Readme
|
# Dev Metrics in Readme
|
||||||
|
|
||||||
[Wakatime](https://wakatime.com) Weekly Metrics on your Profile Readme
|
[Wakatime](https://wakatime.com) Weekly Metrics on your Profile Readme:
|
||||||
|

|
||||||
|
|
||||||
## Update your Readme
|
## Update your Readme
|
||||||
|
|
||||||
@@ -13,18 +14,62 @@ Add a comment to your README like the follows
|
|||||||
|
|
||||||
The lines will be our entrypoints for our metrics.
|
The lines will be our entrypoints for our metrics.
|
||||||
|
|
||||||
## How to get it
|
## Using it
|
||||||
|
|
||||||
- Clone the Repo
|
- Get your Wakatime API Key from your [Account Settings in Wakatime](https://wakatime.com/settings/account) and save it as `WAKATIME_API_KEY = <your wakatime API Key>` in your Repository Secrets
|
||||||
- Install the dependencies `pip install -r requirements.txt`
|
|
||||||
- Get a GitHub Access Token with a `repo` scope.
|
|
||||||
- Get your Wakatime API Key.
|
|
||||||
- Load env vars like
|
|
||||||
|
|
||||||
```text
|
|
||||||
GH_TOKEN = <ghtoken>
|
|
||||||
WAKATIME_API_KEY = <your wakatime API Key>
|
|
||||||
USERNAME = <github_username>
|
|
||||||
```
|
|
||||||
|
|
||||||
- Run the Script with `python main.py`
|
That's it. The Action runs everyday at 00.00 UTC
|
||||||
|
|
||||||
|
### Profile Repository
|
||||||
|
|
||||||
|
If you're executing the workflow on your Profile Repository (`<username>/<username>`)
|
||||||
|
|
||||||
|
**You wouldn't need an GitHub Access Token since GitHub Actions already makes one for you.**
|
||||||
|
|
||||||
|
Here is a sample workflow file for you to get started,
|
||||||
|
|
||||||
|
```yml
|
||||||
|
name: Waka Readme
|
||||||
|
|
||||||
|
on:
|
||||||
|
schedule:
|
||||||
|
# Runs at 12am UTC
|
||||||
|
- cron: '0 0 * * *'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
update-readme:
|
||||||
|
name: Update this repo's README
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: athul/waka-readme@master
|
||||||
|
with:
|
||||||
|
WAKATIME_API_KEY: ${{ secrets.WAKATIME_API_KEY }}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Different Repository than Profile Repository
|
||||||
|
|
||||||
|
if you're executing the workflow on another repo other than `<username>/<username>`
|
||||||
|
|
||||||
|
- You'll need to get a GitHub Access Token with a `repo` scope and save it in the Repo Secrets `GH_TOKEN = <Your GitHub Access Token>`
|
||||||
|
|
||||||
|
Here is Sample Worflow File for running it
|
||||||
|
|
||||||
|
```yml
|
||||||
|
name: Waka Readme
|
||||||
|
|
||||||
|
on:
|
||||||
|
schedule:
|
||||||
|
# Runs at 12am UTC
|
||||||
|
- cron: '0 0 * * *'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
update-readme:
|
||||||
|
name: Update Readme with Metrics
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: athul/waka-readme@master
|
||||||
|
with:
|
||||||
|
WAKATIME_API_KEY: ${{ secrets.WAKATIME_API_KEY }}
|
||||||
|
GH_TOKEN: ${{ secrets.GH_TOKEN}}
|
||||||
|
USERNAME: <username> # optional, it will automaticially use the username that executing the workflow
|
||||||
|
```
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ description: 'Add a Wakatime Coding Activity graph in your Readme'
|
|||||||
inputs:
|
inputs:
|
||||||
GH_TOKEN:
|
GH_TOKEN:
|
||||||
description: 'GitHub access token with Repo scope'
|
description: 'GitHub access token with Repo scope'
|
||||||
|
required: true
|
||||||
default: ${{ github.token }}
|
default: ${{ github.token }}
|
||||||
|
|
||||||
WAKATIME_API_KEY:
|
WAKATIME_API_KEY:
|
||||||
|
|||||||
3
main.py
3
main.py
@@ -53,5 +53,6 @@ if __name__ == '__main__':
|
|||||||
stats = getStats()
|
stats = getStats()
|
||||||
rdmd = decodeReadme(contents.content)
|
rdmd = decodeReadme(contents.content)
|
||||||
newreadme = generatenewReadme(stats=stats, readme=rdmd)
|
newreadme = generatenewReadme(stats=stats, readme=rdmd)
|
||||||
repo.update_file(path=contents.path, message="Updated with Dev Metrics",
|
if newreadme != rdmd:
|
||||||
|
repo.update_file(path=contents.path, message="Updated with Dev Metrics",
|
||||||
content=newreadme, sha=contents.sha, branch="master")
|
content=newreadme, sha=contents.sha, branch="master")
|
||||||
|
|||||||
Reference in New Issue
Block a user