You've already forked wakapi-readme-stats
feat: added ability to generate stats on PR and sent to latest comment on PR
This commit is contained in:
@@ -185,8 +185,17 @@ async def main():
|
||||
init_localization_manager()
|
||||
DBM.i("Managers initialized.")
|
||||
|
||||
if GHM.update_readme(await get_stats()):
|
||||
DBM.g("Readme updated!")
|
||||
stats = await get_stats()
|
||||
if not EM.DEBUG_RUN:
|
||||
if GHM.update_readme(stats):
|
||||
DBM.g("Readme updated!")
|
||||
else:
|
||||
DBM.i("Commenting PR...")
|
||||
pr_data = await DM.get_remote_graphql("get_pr_id", pr_number=EM.PR_NUMBER)
|
||||
pr_id = pr_data["data"]["repository"]["pullRequest"]["id"]
|
||||
await DM.get_remote_graphql("add_pr_comment", pr_id=pr_id, comment=stats)
|
||||
DBM.g("PR commented!")
|
||||
DBM.g("Debug run, readme not updated. check the latest comment for the generated stats.")
|
||||
await DM.close_remote_resources()
|
||||
|
||||
|
||||
|
||||
@@ -121,6 +121,26 @@ GITHUB_API_QUERIES = {
|
||||
}
|
||||
}
|
||||
""",
|
||||
# Query to collect current PR ID
|
||||
# NOTE: Only to be used for PR review not to be used with actual action
|
||||
"get_pr_id": """
|
||||
{
|
||||
repository(owner: "anmol098", name: "waka-readme-stats") {
|
||||
pullRequest(number: $pr_number) {
|
||||
id
|
||||
}
|
||||
}
|
||||
}
|
||||
""",
|
||||
"add_pr_comment": """
|
||||
mutation {
|
||||
addComment(input: {subjectId: "$pr_id", body: "$comment"}) {
|
||||
subject {
|
||||
id
|
||||
}
|
||||
}
|
||||
}
|
||||
"""
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -46,3 +46,4 @@ class EnvironmentManager:
|
||||
|
||||
DEBUG_LOGGING = getenv("INPUT_DEBUG_LOGGING", "0").lower() in _TRUTHY
|
||||
DEBUG_RUN = getenv("DEBUG_RUN", "False").lower() in _TRUTHY
|
||||
PR_NUMBER = getenv("PR_NUMBER", "")
|
||||
|
||||
Reference in New Issue
Block a user