Add Visium breast-cancer tutorial #3
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: PR preview | |
| on: | |
| pull_request: | |
| branches: [main] | |
| paths: | |
| - "**/*.ipynb" | |
| - "tutorials/**" | |
| - "examples/**" | |
| concurrency: | |
| group: preview-pr-${{ github.event.pull_request.number }} | |
| cancel-in-progress: true | |
| # gh-pages publishing needs write access to the repo. | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| preview: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 20 | |
| steps: | |
| - name: Check out notebooks PR (this repo) | |
| uses: actions/checkout@v5 | |
| with: | |
| path: notebooks | |
| ref: ${{ github.event.pull_request.head.sha }} | |
| - name: Check out spatialdata-plot main | |
| uses: actions/checkout@v5 | |
| with: | |
| repository: scverse/spatialdata-plot | |
| path: lib | |
| fetch-depth: 0 | |
| - name: Mount PR notebooks into lib's submodule path | |
| run: | | |
| # Replace the lib's submodule mount with the PR's notebook content | |
| # so the docs build renders the proposed changes. | |
| rm -rf lib/docs/notebooks | |
| cp -R notebooks lib/docs/notebooks | |
| # The lib's .gitmodules still references the public URL — drop it | |
| # for this build so sphinx doesn't get confused by an absent .git | |
| # inside the submodule path. | |
| rm -f lib/.gitmodules | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v7 | |
| - name: Build docs | |
| working-directory: lib | |
| run: uvx --with="virtualenv<21" hatch run docs:build | |
| - name: Deploy preview to gh-pages | |
| uses: peaceiris/actions-gh-pages@v4 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| publish_dir: lib/docs/_build/html | |
| destination_dir: pr-${{ github.event.pull_request.number }} | |
| keep_files: true | |
| commit_message: "Preview for PR #${{ github.event.pull_request.number }}" | |
| - name: Comment preview link on PR | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const pr = context.issue.number; | |
| const owner = context.repo.owner; | |
| const repo = context.repo.repo; | |
| // Use the canonical scverse.org URL directly. The github.io URL | |
| // 301-redirects there because of the org-wide CNAME, which makes | |
| // the displayed link confusingly different from the destination. | |
| const url = `https://scverse.org/${repo}/pr-${pr}/gallery.html`; | |
| const marker = '<!-- preview-link -->'; | |
| const body = `${marker}\n📖 **Docs preview**: ${url}\n\n_Built from ${context.sha.substring(0, 7)}; redeployed on every push._`; | |
| const { data: comments } = await github.rest.issues.listComments({ owner, repo, issue_number: pr }); | |
| const existing = comments.find(c => c.body && c.body.includes(marker)); | |
| if (existing) { | |
| await github.rest.issues.updateComment({ owner, repo, comment_id: existing.id, body }); | |
| } else { | |
| await github.rest.issues.createComment({ owner, repo, issue_number: pr, body }); | |
| } |