Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
github_action: Mention PR where the endpoints were added.
Vector73a5d25826bd70
diff --git a/.github/workflows/api-docs-update-check.yml b/.github/workflows/api-docs-update-check.ymlindex 6a2d41afdf0..4fa0d6241b3 100644--- a/.github/workflows/api-docs-update-check.yml+++ b/.github/workflows/api-docs-update-check.yml@@ -66,6 +66,8 @@ jobs:- name: Run tools/notify-if-api-docs-changedid: run_checkrun: ./tools/notify-if-api-docs-changed >> $GITHUB_OUTPUT+ env:+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}- name: Report status to CZOif: ${{github.repository == 'zulip/zulip'}}diff --git a/tools/notify-if-api-docs-changed b/tools/notify-if-api-docs-changedindex 0f7a241d4d4..dcf05b0a244 100755--- a/tools/notify-if-api-docs-changed+++ b/tools/notify-if-api-docs-changed@@ -1,8 +1,10 @@#!/usr/bin/env python3+import jsonimport osimport reimport sysfrom pathlib import Path+from urllib.request import Request, urlopenTOOLS_DIR = os.path.dirname(os.path.abspath(__file__))os.chdir(os.path.dirname(TOOLS_DIR))@@ -11,11 +13,26 @@ sys.path.insert(0, os.path.dirname(TOOLS_DIR))from zerver.openapi.merge_api_changelogs import get_feature_level-def get_build_url_from_environment() -> str:- server = os.environ["GITHUB_SERVER_URL"]+def get_pull_request_number_or_commit_hash() -> str:+ github_token = os.environ["GITHUB_TOKEN"]repo = os.environ["GITHUB_REPOSITORY"]- run_id = os.environ["GITHUB_RUN_ID"]- return f"{server}/{repo}/actions/runs/{run_id}"+ commit_hash = os.environ["GITHUB_SHA"]++ url = f"https://api.github.com/repos/{repo}/commits/{commit_hash}/pulls"+ headers = {+ "Accept": "application/vnd.github.groot-preview+json",+ "Authorization": f"token {github_token}",+ }++ try:+ req = Request(url, headers=headers)+ with urlopen(req) as response:+ pull_requests = json.load(response)+ if len(pull_requests) > 0:+ return f"#{pull_requests[0]['number']}"+ return commit_hash+ except Exception:+ return commit_hashdef get_changed_api_endpoints() -> list[str]:@@ -41,15 +58,12 @@ def get_changed_api_endpoints() -> list[str]:if __name__ == "__main__":- branch = os.environ.get("GITHUB_REF", "unknown branch").split("/")[-1]- topic = f"{branch} failing"- build_url = get_build_url_from_environment()- github_actor = os.environ.get("GITHUB_ACTOR", "unknown user")+ pull_request = get_pull_request_number_or_commit_hash()feature_level = get_feature_level(update_feature_level=False)endpoints = get_changed_api_endpoints()topic = f"new feature level: {feature_level}"endpoints_string = ", ".join(endpoints)- content = f"[Build]({build_url}) triggered by {github_actor} on branch `{branch}` has updated the API documentation for the following endpoints: {endpoints_string}."+ content = f"{pull_request} has updated the API documentation for the following endpoints: {endpoints_string}."print(f"topic={topic}\ncontent={content}")