Skip to content

Commit bb85f5a

Browse files
committed
ci: Add GitHub Actions workflow for build and release
1 parent b49cbac commit bb85f5a

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

.github/workflows/release.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ jobs:
122122
123123
- name: download MediaMTX binaries
124124
run: python tools/download-mediamtx.py
125+
env:
126+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
125127

126128
- name: lint frontend (continue on error)
127129
run: npm run lint
@@ -194,6 +196,8 @@ jobs:
194196
195197
- name: download MediaMTX binaries
196198
run: python tools/download-mediamtx.py
199+
env:
200+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
197201

198202
- name: lint frontend (continue on error)
199203
run: npm run lint
@@ -267,6 +271,8 @@ jobs:
267271
268272
- name: download MediaMTX binaries
269273
run: python tools/download-mediamtx.py
274+
env:
275+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
270276

271277
- name: lint frontend (continue on error)
272278
run: npm run lint
@@ -341,6 +347,8 @@ jobs:
341347
${{ runner.os }}-cargo-
342348
- name: download MediaMTX binaries
343349
run: python tools/download-mediamtx.py
350+
env:
351+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
344352
- name: lint frontend (continue on error)
345353
run: npm run lint
346354
continue-on-error: true
@@ -402,6 +410,8 @@ jobs:
402410
${{ runner.os }}-cargo-
403411
- name: download MediaMTX binaries
404412
run: python tools/download-mediamtx.py
413+
env:
414+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
405415
- name: lint frontend (continue on error)
406416
run: npm run lint
407417
continue-on-error: true
@@ -464,6 +474,8 @@ jobs:
464474
${{ runner.os }}-cargo-
465475
- name: download MediaMTX binaries
466476
run: python tools/download-mediamtx.py
477+
env:
478+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
467479
- name: lint frontend (continue on error)
468480
run: npm run lint
469481
continue-on-error: true

tools/download-mediamtx.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,26 @@
5353
def get_latest_release():
5454
"""Get latest MediaMTX release info"""
5555
print("[*] Getting latest MediaMTX release info...")
56-
response = requests.get(MEDIAMTX_API_URL)
56+
headers = {"Accept": "application/vnd.github+json"}
57+
58+
token = (
59+
os.environ.get("MEDIAMTX_GITHUB_TOKEN")
60+
or os.environ.get("GITHUB_TOKEN")
61+
or os.environ.get("GH_TOKEN")
62+
)
63+
64+
if token:
65+
headers["Authorization"] = f"Bearer {token}"
66+
67+
response = requests.get(MEDIAMTX_API_URL, headers=headers, timeout=30)
68+
69+
if response.status_code == 403:
70+
reset_at = response.headers.get("X-RateLimit-Reset")
71+
hint = "Set GITHUB_TOKEN or MEDIAMTX_GITHUB_TOKEN env var to increase rate limit."
72+
if reset_at:
73+
hint += f" Rate limit resets at UNIX timestamp {reset_at}."
74+
raise RuntimeError(f"GitHub API rate limit hit (403). {hint}")
75+
5776
response.raise_for_status()
5877
return response.json()
5978

0 commit comments

Comments
 (0)