mirror of
				https://github.com/fastapi/sqlmodel.git
				synced 2025-10-31 10:06:57 +08:00 
			
		
		
		
	♻️ Refactor Deploy Docs GitHub Action to be a script and update token preparing for org (#1039)
This commit is contained in:
		 Sebastián Ramírez
					Sebastián Ramírez
				
			
				
					committed by
					
						 GitHub
						GitHub
					
				
			
			
				
	
			
			
			 GitHub
						GitHub
					
				
			
						parent
						
							d7af50c184
						
					
				
				
					commit
					77374aa016
				
			
							
								
								
									
										31
									
								
								scripts/comment_docs_deploy_url_in_pr.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								scripts/comment_docs_deploy_url_in_pr.py
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,31 @@ | ||||
| import logging | ||||
| import sys | ||||
|  | ||||
| from github import Github | ||||
| from pydantic import SecretStr | ||||
| from pydantic_settings import BaseSettings | ||||
|  | ||||
|  | ||||
| class Settings(BaseSettings): | ||||
|     github_repository: str | ||||
|     github_token: SecretStr | ||||
|     deploy_url: str | ||||
|     commit_sha: str | ||||
|  | ||||
|  | ||||
| if __name__ == "__main__": | ||||
|     logging.basicConfig(level=logging.INFO) | ||||
|     settings = Settings() | ||||
|     logging.info(f"Using config: {settings.model_dump_json()}") | ||||
|     g = Github(settings.github_token.get_secret_value()) | ||||
|     repo = g.get_repo(settings.github_repository) | ||||
|     use_pr = next( | ||||
|         (pr for pr in repo.get_pulls() if pr.head.sha == settings.commit_sha), None | ||||
|     ) | ||||
|     if not use_pr: | ||||
|         logging.error(f"No PR found for hash: {settings.commit_sha}") | ||||
|         sys.exit(0) | ||||
|     use_pr.as_issue().create_comment( | ||||
|         f"📝 Docs preview for commit {settings.commit_sha} at: {settings.deploy_url}" | ||||
|     ) | ||||
|     logging.info("Finished") | ||||
		Reference in New Issue
	
	Block a user