@@ -72,6 +72,21 @@ def clone_data_to_branch_folder(branch_name, remote_url, parent_dir, pr_number=N
7272 os .chdir (parent_dir )
7373
7474
75+ def update_pr_description (pr_number ):
76+ """
77+ Updates PR description by adding the url to access the hosted environment under dev
78+ if it does not already exist in the definition
79+ :param pr_number: PR number for the branch hosting website
80+ """
81+ command = ["gh" , "pr" , "view" , pr_number , "--json" , "body" , "--jq" , "'.body'" ]
82+ pr_description = subprocess .run (command , capture_output = True , text = True ).stdout .strip ()
83+ hosted_url = f"docs-dev.polygon.technology/{ pr_number } "
84+ if hosted_url not in pr_description :
85+ new_pr_description = f"Hosted url: [{ hosted_url } ](https://{ hosted_url } )\n " + pr_description
86+ command = ["gh" , "pr" , "edit" , pr_number , "--body" , new_pr_description ]
87+ subprocess .run (command )
88+
89+
7590def process_branch_folders ():
7691 """
7792 Clones the branch specific code to hosted/<branch-name> folder.
@@ -95,6 +110,7 @@ def process_branch_folders():
95110 continue
96111 pr_number = str (branch_data ["number" ])
97112 clone_data_to_branch_folder (branch_data ["headRefName" ], remote_url , parent_dir , pr_number )
113+ update_pr_description (pr_number )
98114 pr_numbers .append (pr_number )
99115
100116 return pr_numbers
@@ -129,4 +145,4 @@ def update_nginx_config(pr_numbers):
129145if __name__ == "__main__" :
130146 current_dir = os .getcwd ()
131147 pr_numbers = process_branch_folders ()
132- update_nginx_config (pr_numbers )
148+ update_nginx_config (pr_numbers )
0 commit comments