Buckets:

download
raw
2.14 kB
#!/usr/bin/env python3
"""Fix GitHub Pages source branch"""
import os
import sys
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import requests
from github_app_auth import (
REPO_NAME,
REPO_OWNER,
get_headers,
get_installation_token,
)
def fix_pages_source():
"""Update Pages source from master to main"""
try:
token = get_installation_token()
headers = get_headers(token)
print("Updating GitHub Pages source to 'main' branch...")
# Update Pages configuration
url = f"https://api.github.com/repos/{REPO_OWNER}/{REPO_NAME}/pages"
data = {"source": {"branch": "main", "path": "/docs"}}
response = requests.put(url, headers=headers, json=data, timeout=30)
if response.status_code == 204:
print("SUCCESS: Pages source updated to 'main' branch!")
# Trigger a new Pages build by creating a dummy commit
print("\nTriggering new Pages build...")
# Get latest commit on main
commits_url = f"https://api.github.com/repos/{REPO_OWNER}/{REPO_NAME}/commits/main"
commits_resp = requests.get(commits_url, headers=headers, timeout=30)
if commits_resp.status_code == 200:
latest_sha = commits_resp.json().get("sha")
print(f"Latest commit: {latest_sha[:7]}")
# Create a Pages build request
build_url = f"https://api.github.com/repos/{REPO_OWNER}/{REPO_NAME}/pages/builds"
build_resp = requests.post(build_url, headers=headers, timeout=30)
if build_resp.status_code == 201:
print("Pages build triggered successfully!")
else:
print(f"Build trigger status: {build_resp.status_code}")
return True
else:
print(f"Failed to update: {response.status_code}")
print(f"Response: {response.text}")
return False
except Exception as e:
print(f"Error: {e}")
return False
if __name__ == "__main__":
fix_pages_source()

Xet Storage Details

Size:
2.14 kB
·
Xet hash:
a66a2fb77566be6d6f59fa133aa6d08a13072449ea3e9c05e94a6629b95c389b

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.