diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index db28656..7072228 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -9,6 +9,8 @@ on: jobs: generate-page: runs-on: ubuntu-latest + permissions: + contents: read steps: - uses: actions/checkout@v6 @@ -27,13 +29,39 @@ jobs: python src/scripts/generate_page.py python src/scripts/generate_workflow_md.py + - name: Upload page data + uses: actions/upload-artifact@v4 + with: + name: generated-data + path: static/data/*.json + + - name: Upload workflow data + uses: actions/upload-artifact@v4 + with: + name: generated-workflows + path: docs/workflows/all_workflows/*.md + build: name: Build Docusaurus runs-on: ubuntu-latest + needs: generate-page steps: - uses: actions/checkout@v6 with: fetch-depth: 0 + + - name: Download generated data + uses: actions/download-artifact@v4 + with: + name: generated-data + path: static/data/ + + - name: Download generated workflows + uses: actions/download-artifact@v4 + with: + name: generated-workflows + path: docs/workflows/all_workflows/ + - uses: actions/setup-node@v6 with: node-version: 18 diff --git a/.github/workflows/test-deploy.yml b/.github/workflows/test-deploy.yml index 0341026..2420c96 100644 --- a/.github/workflows/test-deploy.yml +++ b/.github/workflows/test-deploy.yml @@ -7,6 +7,8 @@ on: jobs: generate-page: runs-on: ubuntu-latest + permissions: + contents: read steps: - uses: actions/checkout@v6 @@ -25,13 +27,39 @@ jobs: python src/scripts/generate_page.py python src/scripts/generate_workflow_md.py + - name: Upload page data + uses: actions/upload-artifact@v4 + with: + name: generated-data + path: static/data/*.json + + - name: Upload workflow data + uses: actions/upload-artifact@v4 + with: + name: generated-workflows + path: docs/workflows/all_workflows/*.md + test-deploy: name: Test deployment runs-on: ubuntu-latest + needs: generate-page steps: - uses: actions/checkout@v6 with: fetch-depth: 0 + + - name: Download generated data + uses: actions/download-artifact@v4 + with: + name: generated-data + path: static/data/ + + - name: Download generated workflows + uses: actions/download-artifact@v4 + with: + name: generated-workflows + path: docs/workflows/all_workflows/ + - uses: actions/setup-node@v6 with: node-version: 18 @@ -39,5 +67,6 @@ jobs: - name: Install dependencies run: npm ci + - name: Test build website run: npm run build diff --git a/src/scripts/generate_page.py b/src/scripts/generate_page.py index 4d30093..a1afac8 100644 --- a/src/scripts/generate_page.py +++ b/src/scripts/generate_page.py @@ -29,6 +29,15 @@ def get_total_commits(repo): return counts +def get_total_deployments(repo): + """Get total deployments in a repository.""" + try: + counts = repo.get_deployments().totalCount + except: + counts = 0 + return counts + + def get_commit_history(repo): """Get commit history for a repository.""" total = get_total_commits(repo) @@ -80,9 +89,9 @@ def get_config_readme(repo_name): # ---------------------------- # query information from github about the organization gh_instance = Github(auth=Auth.Token(os.environ["GITHUB_TOKEN"])) -logger.info("authenticated to Github as %s", gh_instance.get_user().login) +logger.info("authenticated to Github API") gh_org = gh_instance.get_organization("MPUSP") -logger.info("fetching data for organization %s", gh_org.login) +logger.info("fetching data for organization") # get members and their stats members = {} @@ -123,7 +132,7 @@ def get_config_readme(repo_name): else None ), "contributors": repo.get_contributors().totalCount, - "deployments": repo.get_deployments().totalCount, + "deployments": get_total_deployments(repo), "downloads": sum( asset.download_count for release in repo.get_releases()