Merge pull request #5 from joe733/master

fix: Added WakaTime info; Some tweaks
This commit is contained in:
Athul Cyriac Ajay
2020-07-12 22:55:35 +05:30
committed by GitHub
2 changed files with 25 additions and 18 deletions

View File

@@ -1,32 +1,41 @@
# 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:
![Project Preview](https://user-images.githubusercontent.com/8397274/87243943-e6b45c00-c457-11ea-94c9-2aa0bf241be8.png) ![Project Preview](https://user-images.githubusercontent.com/8397274/87243943-e6b45c00-c457-11ea-94c9-2aa0bf241be8.png)
## New to WakaTime
WakaTime gives you an idea of the time you really spent on coding. This helps you boost your productivity and competitive edge.
- Head over to https://wakatime.com and create an account.
- Get your WakaTime API Key from your [Account Settings in WakaTime](https://wakatime.com/settings/account).
- Install the [WakaTime plugin](https://wakatime.com/plugins) in your favourite editor / IDE.
- Paste in your API key to start the analysis.
## Update your Readme ## Update your Readme
Add a comment to your README like the follows Add a comment to your `README.md` like this:
```md ```md
<!--START_SECTION:waka--> <!--START_SECTION:waka-->
<!--END_SECTION:waka--> <!--END_SECTION:waka-->
``` ```
The lines will be our entrypoints for our metrics. These lines will be our entry-points for the dev metrics.
## Using it ## Using it
- 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 Save your WakaTime API Key as `WAKATIME_API_KEY = <your wakatime API Key>` in your [Repository Secrets](https://docs.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets).
That's it. The Action runs everyday at 00.00 UTC That's it! The Action runs everyday at 00.00 UTC
### Profile Repository ### Profile Repository
If you're executing the workflow on your Profile Repository (`<username>/<username>`) *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.** > 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, Here is a sample workflow file for you to get started:
```yml ```yml
name: Waka Readme name: Waka Readme
@@ -46,13 +55,13 @@ jobs:
WAKATIME_API_KEY: ${{ secrets.WAKATIME_API_KEY }} WAKATIME_API_KEY: ${{ secrets.WAKATIME_API_KEY }}
``` ```
### Different Repository than Profile Repository ### Other Repository (not Profile)
if you're executing the workflow on another repo other than `<username>/<username>` *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>` You'll need to get a [GitHub Access Token](https://docs.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_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 Here is Sample Worflow File for running it:
```yml ```yml
name: Waka Readme name: Waka Readme
@@ -70,6 +79,6 @@ jobs:
- uses: athul/waka-readme@master - uses: athul/waka-readme@master
with: with:
WAKATIME_API_KEY: ${{ secrets.WAKATIME_API_KEY }} WAKATIME_API_KEY: ${{ secrets.WAKATIME_API_KEY }}
GH_TOKEN: ${{ secrets.GH_TOKEN}} GH_TOKEN: ${{ secrets.GH_TOKEN }}
USERNAME: <username> # optional, it will automaticially use the username that executing the workflow USERNAME: <username> # optional, it will automatically use the username of the owner of the repository who's executing the workflow.
``` ```

View File

@@ -36,14 +36,12 @@ def getStats():
def decodeReadme(data: str): def decodeReadme(data: str):
decodedBytes = base64.b64decode(data) decodedBytes = base64.b64decode(data)
decodedStr = str(decodedBytes, "utf-8") return str(decodedBytes, "utf-8")
return decodedStr
def generatenewReadme(stats: str, readme: str): def generatenewReadme(stats: str, readme: str):
statsinReadme = f"{START_COMMENT}\n{stats}\n{END_COMMENT}" statsinReadme = f"{START_COMMENT}\n{stats}\n{END_COMMENT}"
newReadme = re.sub(listReg, statsinReadme, readme) return re.sub(listReg, statsinReadme, readme)
return newReadme
if __name__ == '__main__': if __name__ == '__main__':