Skip to content

Commit

Permalink
cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
trivialfis committed Feb 7, 2025
1 parent c23b27c commit 76c850c
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions ops/pipeline/trigger-rtd.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@ def trigger_build(token: str) -> None:
"""Trigger RTD build."""

event_path = os.environ["GITHUB_EVENT_PATH"]
print(f"Event path: {event_path}")
with open(event_path, "r") as fd:
event: dict = json.load(fd)
print(f"Event: {event}")

if event.get("pull_request", None) is None:
# refs/heads/branch-name
Expand All @@ -27,15 +25,11 @@ def trigger_build(token: str) -> None:
branch = event["pull_request"]["number"]

URL = f"https://readthedocs.org/api/v3/projects/xgboost/versions/{branch}/builds/"
print(f"URL: {URL}")
HEADERS = {"Authorization": f"token {token}"}
response = requests.post(URL, headers=HEADERS)
print("response:", response)
# 202 means the build is successfully triggered.
assert response.status_code == 202
response = response.json()
msg = json.dumps(response, indent=2)
print("response:", response)
assert response.json()


if __name__ == "__main__":
Expand All @@ -44,7 +38,6 @@ def trigger_build(token: str) -> None:
# (expose) the token in the CI.
assert token is not None
if not isinstance(token, str) or len(token) != 40:
# fixme: remove this once we have a valid token
raise ValueError(f"Invalid token: {len(token)}")
raise ValueError(f"Invalid token.")

trigger_build(token)

0 comments on commit 76c850c

Please sign in to comment.