Skip to content

Commit 3170eb6

Browse files
authored
feat: various improvements to enable building page
fix: gh actions workflow permissions and queries
2 parents 4116001 + 7f74cbf commit 3170eb6

3 files changed

Lines changed: 69 additions & 3 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ on:
99
jobs:
1010
generate-page:
1111
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
1214
steps:
1315
- uses: actions/checkout@v6
1416

@@ -27,13 +29,39 @@ jobs:
2729
python src/scripts/generate_page.py
2830
python src/scripts/generate_workflow_md.py
2931
32+
- name: Upload page data
33+
uses: actions/upload-artifact@v4
34+
with:
35+
name: generated-data
36+
path: static/data/*.json
37+
38+
- name: Upload workflow data
39+
uses: actions/upload-artifact@v4
40+
with:
41+
name: generated-workflows
42+
path: docs/workflows/all_workflows/*.md
43+
3044
build:
3145
name: Build Docusaurus
3246
runs-on: ubuntu-latest
47+
needs: generate-page
3348
steps:
3449
- uses: actions/checkout@v6
3550
with:
3651
fetch-depth: 0
52+
53+
- name: Download generated data
54+
uses: actions/download-artifact@v4
55+
with:
56+
name: generated-data
57+
path: static/data/
58+
59+
- name: Download generated workflows
60+
uses: actions/download-artifact@v4
61+
with:
62+
name: generated-workflows
63+
path: docs/workflows/all_workflows/
64+
3765
- uses: actions/setup-node@v6
3866
with:
3967
node-version: 18

.github/workflows/test-deploy.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ on:
77
jobs:
88
generate-page:
99
runs-on: ubuntu-latest
10+
permissions:
11+
contents: read
1012
steps:
1113
- uses: actions/checkout@v6
1214

@@ -25,19 +27,46 @@ jobs:
2527
python src/scripts/generate_page.py
2628
python src/scripts/generate_workflow_md.py
2729
30+
- name: Upload page data
31+
uses: actions/upload-artifact@v4
32+
with:
33+
name: generated-data
34+
path: static/data/*.json
35+
36+
- name: Upload workflow data
37+
uses: actions/upload-artifact@v4
38+
with:
39+
name: generated-workflows
40+
path: docs/workflows/all_workflows/*.md
41+
2842
test-deploy:
2943
name: Test deployment
3044
runs-on: ubuntu-latest
45+
needs: generate-page
3146
steps:
3247
- uses: actions/checkout@v6
3348
with:
3449
fetch-depth: 0
50+
51+
- name: Download generated data
52+
uses: actions/download-artifact@v4
53+
with:
54+
name: generated-data
55+
path: static/data/
56+
57+
- name: Download generated workflows
58+
uses: actions/download-artifact@v4
59+
with:
60+
name: generated-workflows
61+
path: docs/workflows/all_workflows/
62+
3563
- uses: actions/setup-node@v6
3664
with:
3765
node-version: 18
3866
cache: npm
3967

4068
- name: Install dependencies
4169
run: npm ci
70+
4271
- name: Test build website
4372
run: npm run build

src/scripts/generate_page.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,15 @@ def get_total_commits(repo):
2929
return counts
3030

3131

32+
def get_total_deployments(repo):
33+
"""Get total deployments in a repository."""
34+
try:
35+
counts = repo.get_deployments().totalCount
36+
except:
37+
counts = 0
38+
return counts
39+
40+
3241
def get_commit_history(repo):
3342
"""Get commit history for a repository."""
3443
total = get_total_commits(repo)
@@ -80,9 +89,9 @@ def get_config_readme(repo_name):
8089
# ----------------------------
8190
# query information from github about the organization
8291
gh_instance = Github(auth=Auth.Token(os.environ["GITHUB_TOKEN"]))
83-
logger.info("authenticated to Github as %s", gh_instance.get_user().login)
92+
logger.info("authenticated to Github API")
8493
gh_org = gh_instance.get_organization("MPUSP")
85-
logger.info("fetching data for organization %s", gh_org.login)
94+
logger.info("fetching data for organization")
8695

8796
# get members and their stats
8897
members = {}
@@ -123,7 +132,7 @@ def get_config_readme(repo_name):
123132
else None
124133
),
125134
"contributors": repo.get_contributors().totalCount,
126-
"deployments": repo.get_deployments().totalCount,
135+
"deployments": get_total_deployments(repo),
127136
"downloads": sum(
128137
asset.download_count
129138
for release in repo.get_releases()

0 commit comments

Comments
 (0)