Skip to content

Commit

Permalink
Authenticate fetches in gh-data.py when run as GH Action
Browse files Browse the repository at this point in the history
These currently sometimes fail.
  • Loading branch information
zcorpan committed Feb 17, 2025
1 parent d94a0e6 commit 71f3c39
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ jobs:
git merge ${{ github.sha }} --strategy recursive -X theirs --no-edit
- name: Generate Merged Data
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
python3 gh-data.py
python3 merge-data.py
Expand Down
6 changes: 6 additions & 0 deletions gh-data.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
import json, os, requests, re, sys


# Retrieve the token from environment variables
token = os.getenv('GITHUB_TOKEN')
headers = {"Authorization": f"token {token}"} if token else {}


# Utilities
def write_json(filename, data):
with open(filename, "w") as f:
Expand Down Expand Up @@ -164,6 +169,7 @@ def main():
print(f"Fetching page {page}...")
response = requests.get(
f"https://api.github.com/repos/mozilla/standards-positions/issues?direction=asc&state=all&per_page=100&page={page}",
headers=headers,
timeout=5,
)
response.raise_for_status()
Expand Down

0 comments on commit 71f3c39

Please sign in to comment.