-
Notifications
You must be signed in to change notification settings - Fork 0
57 lines (46 loc) · 1.69 KB
/
update-site.yml
File metadata and controls
57 lines (46 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
name: Generate Tutorials Index
on:
workflow_dispatch:
jobs:
generate-tutorials-index:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Generate tutorials.json
env:
GH_USERNAME: Boernsman
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} # or a PAT if needed
run: |
python3 <<EOF
import requests, json
headers = {
"Accept": "application/vnd.github.mercy-preview+json",
"Authorization": f"token '{os.environ['GH_TOKEN']}'"
}
res = requests.get(f"https://api.github.com/users/{os.environ['GH_USERNAME']}/repos", headers=headers)
repos = res.json()
tutorials = []
for repo in repos:
if not repo.get('fork'):
r = requests.get(repo['url'], headers=headers).json()
if 'topics' in r and 'tutorial' in r['topics']:
tutorials.append({
"name": repo["name"],
"html_url": repo["html_url"],
"description": repo.get("description", "")
})
with open("tutorials.json", "w") as f:
json.dump(tutorials, f, indent=2)
EOF
- name: Commit and push tutorials.json
run: |
git config user.name "github-actions"
git config user.email "actions@github.com"
git add tutorials.json
git commit -m "Update tutorials index" || echo "No changes to commit"
git push