add commit with own name and email config

This commit is contained in:
dmego
2021-04-08 13:39:23 +08:00
parent b5edd2b8c1
commit 4bac89fb42
2 changed files with 12 additions and 2 deletions

10
main.py
View File

@@ -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',