Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/manifest-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ jobs:
with:
python-version: '3.12'
- name: Generate preview from public sources
env:
GITHUB_TOKEN: ${{ github.token }}
run: python scripts/sync-docs.py
- uses: actions/upload-artifact@v4
with:
Expand Down
30 changes: 20 additions & 10 deletions scripts/sync-docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import re
import subprocess
import tempfile
import time
import tomllib
import urllib.error
import urllib.request
Expand Down Expand Up @@ -48,16 +49,25 @@ def load_manifest(path):


def release(org, repo):
request = urllib.request.Request(f'https://api.github.com/repos/{org}/{repo}/releases/latest',
headers={'Accept': 'application/vnd.github+json', 'User-Agent': 'crewloom-docs-sync'})
try:
with urllib.request.urlopen(request, timeout=30) as response:
value = json.load(response)
return {'tag': value['tag_name'], 'url': value['html_url'], 'published_at': value['published_at']}
except urllib.error.HTTPError as error:
if error.code == 404:
return None
raise
headers = {'Accept': 'application/vnd.github+json', 'User-Agent': 'crewloom-docs-sync'}
token = os.environ.get('GITHUB_TOKEN')
if token:
headers['Authorization'] = f'Bearer {token}'
request = urllib.request.Request(f'https://api.github.com/repos/{org}/{repo}/releases/latest', headers=headers)
for attempt in range(3):
try:
with urllib.request.urlopen(request, timeout=30) as response:
value = json.load(response)
return {'tag': value['tag_name'], 'url': value['html_url'], 'published_at': value['published_at']}
except urllib.error.HTTPError as error:
if error.code == 404:
return None
# Shared runner IPs can hit the unauthenticated rate limit; retry transient errors.
if error.code in (403, 429) or error.code >= 500:
if attempt < 2:
time.sleep(2 * (attempt + 1))
continue
raise


def collect(project, checkout, latest):
Expand Down
Loading