|
| 1 | +name: Playground Comment |
| 2 | + |
| 3 | +# Greets every new PR with a one-click way to test the changes live: the pkg.pr.new |
| 4 | +# preview build (published by preview.yml) loaded into the hosted playground — no install, |
| 5 | +# no release needed. |
| 6 | +# |
| 7 | +# Uses `pull_request_target` so it can comment on PRs from forks too (the default |
| 8 | +# `pull_request` token is read-only for fork PRs). This is safe here because the job NEVER |
| 9 | +# checks out or runs PR code — it only posts a static comment via the GitHub API. |
| 10 | + |
| 11 | +on: |
| 12 | + pull_request_target: |
| 13 | + types: [opened] |
| 14 | + |
| 15 | +permissions: |
| 16 | + pull-requests: write |
| 17 | + |
| 18 | +jobs: |
| 19 | + comment: |
| 20 | + runs-on: ubuntu-latest |
| 21 | + # Skip bot-authored PRs (e.g. dependabot) — the playground note isn't useful there. |
| 22 | + if: ${{ github.event.pull_request.user.type != 'Bot' }} |
| 23 | + steps: |
| 24 | + - uses: actions/github-script@v7 |
| 25 | + with: |
| 26 | + script: | |
| 27 | + const pr = context.issue.number; |
| 28 | + const author = context.payload.pull_request.user.login; |
| 29 | + const build = `https://pkg.pr.new/slack-blocks-to-jsx@${pr}`; |
| 30 | + const body = [ |
| 31 | + `👋 Thanks for the PR, @${author}!`, |
| 32 | + ``, |
| 33 | + `You can try these changes **live, before any release** — no install needed.`, |
| 34 | + `Once the preview build finishes (see the **pkg-pr-new** bot comment), open the playground and load this PR's build:`, |
| 35 | + ``, |
| 36 | + `🛝 **Playground:** https://slack-block-to-jsx-playground.vercel.app/`, |
| 37 | + `📦 **This PR's build:** \`${build}\``, |
| 38 | + ``, |
| 39 | + `Paste the build URL into the **Library package** field (or hit the **pkg.pr #${pr}** preset) and click **Load build** — your blocks render against this exact PR. 🎉`, |
| 40 | + ].join("\n"); |
| 41 | + await github.rest.issues.createComment({ |
| 42 | + owner: context.repo.owner, |
| 43 | + repo: context.repo.repo, |
| 44 | + issue_number: pr, |
| 45 | + body, |
| 46 | + }); |
0 commit comments