-
-
Notifications
You must be signed in to change notification settings - Fork 671
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
👷 Refactor GitHub Action to comment docs deployment URLs and update t…
…oken, preparing for GitHub org (#896)
- Loading branch information
Showing
6 changed files
with
57 additions
and
92 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
PyGithub>=2.3.0,<3.0.0 | ||
pydantic>=2.5.3,<3.0.0 | ||
pydantic-settings>=2.1.0,<3.0.0 | ||
httpx>=0.27.0,<0.28.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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") |