Add flag to specify a commit message of user's choice (#25)

* Make commit message configurable
Fixes #24

* Update Readme for Commit_message flag

Make commit message configurable #24
This commit is contained in:
Athul Cyriac Ajay 2020-08-02 17:50:23 +05:30 committed by GitHub
parent fa74a6bca2
commit 442c0dae4d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 1 deletions

View File

@ -145,3 +145,16 @@ Markdown 52 mins █░░░░░░░░░░░░░░░
Docker 16 mins ░░░░░░░░░░░░░░░░░░░░░░░░░ 02.32 % Docker 16 mins ░░░░░░░░░░░░░░░░░░░░░░░░░ 02.32 %
YAML 7 mins ░░░░░░░░░░░░░░░░░░░░░░░░░ 01.07 % YAML 7 mins ░░░░░░░░░░░░░░░░░░░░░░░░░ 01.07 %
``` ```
2. You can specify a commit message to overrdie the default _"Updated the Graph with new Metrics"_. Here is how you do it
```yml
- uses: athul/waka-readme@master
with:
WAKATIME_API_KEY: ${{ secrets.WAKATIME_API_KEY }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
USERNAME: <username>
COMMIT_MESSAGE: Updated the Readme
```
If no commit message is specified in the `yml` file, it defaults to _"Updated the Graph with new Metrics"_

View File

@ -21,6 +21,11 @@ inputs:
description: "Displays the week number and days in Readme as title" description: "Displays the week number and days in Readme as title"
default: false default: false
required: false required: false
COMMIT_MESSAGE:
description: "Add a commit message of your choice"
default: "Updated the Graph with new Metrics"
required: false
runs: runs:

View File

@ -18,6 +18,7 @@ user = os.getenv('INPUT_USERNAME')
waka_key = os.getenv('INPUT_WAKATIME_API_KEY') waka_key = os.getenv('INPUT_WAKATIME_API_KEY')
ghtoken = os.getenv('INPUT_GH_TOKEN') ghtoken = os.getenv('INPUT_GH_TOKEN')
show_title = os.getenv("INPUT_SHOW_TITLE") show_title = os.getenv("INPUT_SHOW_TITLE")
commit_message = os.getenv("INPUT_COMMIT_MESSAGE")
def this_week() -> str: def this_week() -> str:
@ -93,5 +94,5 @@ if __name__ == '__main__':
rdmd = decode_readme(contents.content) rdmd = decode_readme(contents.content)
new_readme = generate_new_readme(stats=waka_stats, readme=rdmd) new_readme = generate_new_readme(stats=waka_stats, readme=rdmd)
if new_readme != rdmd: if new_readme != rdmd:
repo.update_file(path=contents.path, message='Updated with Dev Metrics', repo.update_file(path=contents.path, message=commit_message,
content=new_readme, sha=contents.sha, branch='master') content=new_readme, sha=contents.sha, branch='master')