Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .github/workflows/pr-playground-preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: PR Playground Preview

on:
workflow_run:
workflows: ["Test"]
types:
- completed

concurrency:
group: ${{ github.workflow }}-${{ github.event.workflow_run.head_branch }}
cancel-in-progress: true

permissions: {}

jobs:
playground-preview:
name: Add Playground preview to PR
runs-on: ubuntu-24.04
if: >
github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'success'
permissions:
contents: read
pull-requests: write

steps:
- name: Get PR number
id: pr
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
with:
script: |
const prs = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
head: `${context.payload.workflow_run.head_repository.owner.login}:${context.payload.workflow_run.head_branch}`,
state: 'open',
});
if (!prs.data.length) throw new Error('No open PR found for this branch');
core.setOutput('number', prs.data[0].number);

- name: Post Playground preview button
uses: WordPress/action-wp-playground-pr-preview@c8607529dac8d2bf9a1e8493865fc97cd1c3c87b # v2
with:
mode: append-to-description
plugin-path: .
pr-number: ${{ steps.pr.outputs.number }}
github-token: ${{ secrets.GITHUB_TOKEN }}
Loading