From f455523de58de4d7d015da1f791e42bb2efee083 Mon Sep 17 00:00:00 2001 From: Sebastiaan Speck <12570668+sebastiaanspeck@users.noreply.github.com> Date: Mon, 1 Sep 2025 20:17:00 +0200 Subject: [PATCH] scripts/send-to-bot.py: add the commit hash in the message (#17932) --- scripts/send-to-bot.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/scripts/send-to-bot.py b/scripts/send-to-bot.py index df65aa415e..ab59a8be42 100755 --- a/scripts/send-to-bot.py +++ b/scripts/send-to-bot.py @@ -9,7 +9,8 @@ BOT_URL = "https://tldr-bot.starbeamrainbowlabs.com" COMMENT_ERROR = """ -The [build](https://github.com/tldr-pages/tldr/actions/runs/{build_id}) for this PR failed with the following error(s): +The [build](https://github.com/tldr-pages/tldr/actions/runs/{build_id}) for this PR failed +on commit [`{commit_sha}`](https://github.com/{repo_slug}/commit/{commit_sha}) with the following error(s): ``` {content} @@ -20,7 +21,8 @@ Please fix the error(s) and push again. COMMENT_CHECK = """ -Hello! I've noticed something unusual when checking this PR: +Hello! I've noticed something unusual when checking this PR +at commit [`{commit_sha}`](https://github.com/{repo_slug}/commit/{commit_sha}): {content} @@ -60,9 +62,18 @@ def main(action): content = sys.stdin.read().strip() if action == "report-errors": - comment_body = COMMENT_ERROR.format(build_id=BUILD_ID, content=content) + comment_body = COMMENT_ERROR.format( + build_id=BUILD_ID, + commit_sha=COMMIT_SHA, + repo_slug=REPO_SLUG, + content=content, + ) elif action == "report-check-results": - comment_body = COMMENT_CHECK.format(content=content) + comment_body = COMMENT_CHECK.format( + commit_sha=COMMIT_SHA, + repo_slug=REPO_SLUG, + content=content, + ) if post_comment(PR_ID, comment_body): print("Success.") @@ -76,8 +87,9 @@ if __name__ == "__main__": REPO_SLUG = os.environ.get("GITHUB_REPOSITORY") PR_ID = os.environ.get("PULL_REQUEST_ID") BUILD_ID = os.environ.get("GITHUB_RUN_ID") + COMMIT_SHA = os.environ.get("GITHUB_SHA") - if PR_ID is None or BUILD_ID is None or REPO_SLUG is None: + if PR_ID is None or BUILD_ID is None or REPO_SLUG is None or COMMIT_SHA is None: print("Needed environment variables are not set.", file=sys.stderr) sys.exit(1)