Button
A button that runs your repo.
Put it in your README. Whoever clicks it sees your repo, signs in and gets a running copy in a box of their own. Nothing starts until they say so.
The button
For visitorsGoes in your README. It runs your default branch, or the branch you paste, for anyone who wants to try the project. Copy it once and you're done.
Pull request links
Optional, GitHub onlyA small GitHub Action you add once. On each new pull request it comments a link that runs that pull request's code, so reviewers can try a change before merging it. Set it up
Pull request links
Separate from the button, and optional. Add this workflow to your default branch as .github/workflows/pyrovue.yml. It comments a link on each new pull request that runs it in a fresh box. Nothing starts until someone clicks.
It only comments, and never checks out the pull request's code. Do not add a checkout step to it.
# Comments a link that runs each new pull request in a fresh box on pyrovue.
# It only comments: it never checks out or runs the pull request's code, which keeps pull_request_target safe.
# Do not add a checkout step to this workflow.
# pull_request_target runs this file from the default branch, so merge it there first.
name: Run on pyrovue
on:
pull_request_target:
types: [opened, reopened]
permissions:
pull-requests: write
jobs:
link:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
script: |
const origin = "https://pyrovue.com";
const marker = "<!-- pyrovue-run-pr -->";
const badge = "[]";
const text = "Run this pull request in a fresh box on pyrovue. It runs the code in this pull request.";
const { owner, repo } = context.repo;
const number = context.payload.pull_request.number;
const comments = await github.paginate(github.rest.issues.listComments, { owner, repo, issue_number: number, per_page: 100 });
// One comment per pull request: reopening it adds none.
if (comments.some((c) => c.user?.type === "Bot" && c.body?.includes(marker))) return;
const link = `${origin}/github.com/${owner}/${repo}/pull/${number}?ref=pr`;
const body = [marker, badge + "(" + link + ")", "", text].join("\n");
await github.rest.issues.createComment({ owner, repo, issue_number: number, body });