Skip to content

Deploy cross-build metadata file through GitHub Pages site#5642

Merged
agriyakhetarpal merged 5 commits intomainfrom
gh-pages-cross-build-metadata
May 19, 2025
Merged

Deploy cross-build metadata file through GitHub Pages site#5642
agriyakhetarpal merged 5 commits intomainfrom
gh-pages-cross-build-metadata

Conversation

@agriyakhetarpal
Copy link
Member

@agriyakhetarpal agriyakhetarpal commented May 16, 2025

Description

This PR adds a GitHub Pages workflow that runs from the main branch in order to deploy the cross-build metadata file through pyodide.github.io, in order to circumvent GitHub's rate limits against unauthorised requests.

See pyodide/pyodide-build#203 and pypa/cibuildwheel#2002 for more information.

This should trigger on each push to the main branch, so that we can edit the metadata file with ease and it will automatically deploy after that. I've also added workflow_dispatch: trigger and a CRON job one.

@hoodmane and @ryanking, could either of you set up branch protection rules for this gh-pages branch?

cc @joerick (and h/t for the idea!)

Checklists

  • Add a CHANGELOG entry
  • Add / update tests
  • Add new / update outdated documentation

@agriyakhetarpal agriyakhetarpal force-pushed the gh-pages-cross-build-metadata branch from 821e0a8 to 7554b44 Compare May 16, 2025 20:29
@agriyakhetarpal agriyakhetarpal marked this pull request as draft May 16, 2025 20:30
@agriyakhetarpal agriyakhetarpal changed the title Host cross-build metadata file through GitHub Pages site Update cross-build metadata file hosted through GitHub Pages site May 16, 2025
@hoodmane
Copy link
Member

branch protection rules for this gh-pages branch?

What do you want? No force push?

@hoodmane
Copy link
Member

I set the default branch protection rule on it.

@joerick
Copy link
Contributor

joerick commented May 18, 2025

cc @joerick (and h/t for the idea!), could you please confirm if this is what you had in mind?

Since you tagged me, I'll add my two cents! I'd say a better solution would be to have an action deploy that file from main. That saves the extra PR for you to merge, and also allows more adaptability, letting you edit that file at any time, rather than needing the update job to do it.

Something like this would work, I think:

name: Deploy pyodide-cross-build-environments.json to Pages

on:
  push:
    branches:
      - main
    paths:
      # Only runs if this specific file changes
      - pyodide-cross-build-environments.json

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
  contents: read
  pages: write
  id-token: write

jobs:
  deploy:
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}/api/pyodide-cross-build-environments.json
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Setup Pages
        uses: actions/configure-pages@v5

      - name: Prepare artifact
        run: |
          mkdir -p ./_site/api
          cp pyodide-cross-build-environments.json ./_site/api/pyodide-cross-build-environments.json

      - name: Upload artifact
        uses: actions/upload-pages-artifact@v3
        with:
          path: ./_site

      - name: Deploy to GitHub Pages
        id: deployment
        uses: actions/deploy-pages@v4

@agriyakhetarpal
Copy link
Member Author

Since you tagged me, I'll add my two cents! I'd say a better solution would be to have an action deploy that file from main. That saves the extra PR for you to merge, and also allows more adaptability, letting you edit that file at any time, rather than needing the update job to do it.

Great suggestion, thank you, @joerick! I think this makes sense to me, I'll switch to your action instead. Just one clarification: doing this will only prevent the extra PR, as the file is in the gh-pages branch and can be edited at any time, even right now.

Once I change to your suggestion, I'll move from "Deploy from a branch" to "GitHub Actions".

agriyakhetarpal and others added 3 commits May 19, 2025 19:42
@agriyakhetarpal
Copy link
Member Author

agriyakhetarpal commented May 19, 2025

branch protection rules for this gh-pages branch?

What do you want? No force push?

I set the default branch protection rule on it.

Thanks @hoodmane, that helps! Also, if you could add another rule that allows only known collaborators to push to the gh-pages branch, that would be great.

Actually, this is no longer needed – we can drop the gh-pages branch altogether now.

Edit 2: I can't delete it as it's now a protected branch – could you delete it from https://github.com/pyodide/pyodide/branches?

@agriyakhetarpal
Copy link
Member Author

I haven't added [skip ci] to the commit message as we'll want this workflow to run now. I additionally added the workflow_dispatch: and made it run on a scheduled job as well, as an extra measure if GitHub ever is down for some time and it doesn't run when merging a PR – it'll run on the next day, at least.

@agriyakhetarpal agriyakhetarpal changed the title Update cross-build metadata file hosted through GitHub Pages site Deploy cross-build metadata file through GitHub Pages site May 19, 2025
@agriyakhetarpal
Copy link
Member Author

We'll have to merge this to trigger the change, so I shall press the button for now! I've updated the PR title and description accordingly.

@agriyakhetarpal agriyakhetarpal marked this pull request as ready for review May 19, 2025 14:35
@agriyakhetarpal agriyakhetarpal merged commit ba1489c into main May 19, 2025
10 of 14 checks passed
@agriyakhetarpal agriyakhetarpal deleted the gh-pages-cross-build-metadata branch May 19, 2025 14:42
@agriyakhetarpal
Copy link
Member Author

I triggered a successful run through a manual trigger: https://github.com/pyodide/pyodide/actions/runs/15116045722

The metadata file is live at https://pyodide.github.io/pyodide/api/pyodide-cross-build-environments.json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants