From 4bac89fb42a750b696c89d135252870c61bf7d54 Mon Sep 17 00:00:00 2001 From: dmego Date: Thu, 8 Apr 2021 13:39:23 +0800 Subject: [PATCH] add commit with own name and email config --- action.yml | 4 ++++ main.py | 10 ++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 01ee2df..ad833cd 100644 --- a/action.yml +++ b/action.yml @@ -77,6 +77,10 @@ inputs: description: "Show stats in your own language" default: "en" + COMMIT_BY_ME: + required: false + description: "Git commit with your own name and email" + default: "False" runs: using: 'docker' diff --git a/main.py b/main.py index e318231..6042fe8 100644 --- a/main.py +++ b/main.py @@ -41,12 +41,14 @@ showLocChart = os.getenv('INPUT_SHOW_LOC_CHART') show_profile_view = os.getenv('INPUT_SHOW_PROFILE_VIEWS') show_short_info = os.getenv('INPUT_SHOW_SHORT_INFO') locale = os.getenv('INPUT_LOCALE') +commit_by_me = os.getenv('INPUT_COMMIT_BY_ME') show_waka_stats = 'y' # The GraphQL query to get commit data. userInfoQuery = """ { viewer { login + email id } } @@ -484,8 +486,9 @@ if __name__ == '__main__': headers = {"Authorization": "Bearer " + ghtoken} user_data = run_query(userInfoQuery) # Execute the query username = user_data["data"]["viewer"]["login"] + email = user_data["data"]["viewer"]["email"] id = user_data["data"]["viewer"]["id"] - print(username) + print("Username " + username + ", Email " + email) repo = g.get_repo(f"{username}/{username}") contents = repo.get_readme() try: @@ -499,7 +502,10 @@ if __name__ == '__main__': # star_me() rdmd = decode_readme(contents.content) new_readme = generate_new_readme(stats=waka_stats, readme=rdmd) - committer = InputGitAuthor('readme-bot', '41898282+github-actions[bot]@users.noreply.github.com') + if commit_by_me.lower() in truthy: + committer = InputGitAuthor(username, email) + else: + committer = InputGitAuthor('readme-bot', '41898282+github-actions[bot]@users.noreply.github.com') if new_readme != rdmd: try: repo.update_file(path=contents.path, message='Updated with Dev Metrics',