-
Notifications
You must be signed in to change notification settings - Fork 5
81 lines (72 loc) · 3.38 KB
/
pr-build-live-branch.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
name: Build Live Branch
on:
pull_request:
branches:
- trunk
paths-ignore:
- 'docs/**'
- 'examples/**'
- 'bin/**'
- '**/tests/**'
- '**/*.md'
- '.github/**'
- '!.github/workflows/pr-build-live-branch.yml'
- '!.github/workflows/scripts/generate-playground-blueprint.js'
concurrency:
# Cancel concurrent jobs on pull_request but not push, by including the run_id in the concurrency group for the latter.
group: build-${{ github.event_name == 'push' && github.run_id || 'pr' }}-${{ github.ref }}
cancel-in-progress: true
env:
FORCE_COLOR: 1
permissions: {}
jobs:
build:
if: github.repository_owner == 'Automattic' && github.event.pull_request.draft == false && github.event.pull_request.user.login != 'github-actions[bot]'
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
repository-projects: write
id-token: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
- name: Setup Node.js
uses: Automattic/vip-actions/nodejs-setup@trunk
with:
node-version-file: .nvmrc
ignore-scripts: true
- name: Prepare plugin zips
id: prepare
run: |
echo "Generating zip file..."
cd "$GITHUB_WORKSPACE" || exit
npm run plugin-zip
echo "Generated zip file..."
mkdir "$GITHUB_WORKSPACE/zips"
mv remote-data-blocks.zip "$GITHUB_WORKSPACE/zips/remote-data-blocks.zip"
echo "Moved zip file to zips directory..."
mkdir "$GITHUB_WORKSPACE/unzips"
echo "Created unzips directory..."
unzip "$GITHUB_WORKSPACE/zips/remote-data-blocks.zip" -d "$GITHUB_WORKSPACE/unzips/remote-data-blocks"
echo "Unzipped zip file..."
- name: Create playground artifact
id: create-playground-artifact-step
uses: actions/upload-artifact@v4
with:
name: remote-data-blocks-${{ github.event.pull_request.number }}
path: unzips/remote-data-blocks
retention-days: 7
if-no-files-found: 'error'
overwrite: true
- name: Create comment with Playground preview
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
Test this PR in [WordPress Playground](https://playground.wordpress.net/#{"landingPage":"/wp-admin/admin.php?page=remote-data-blocks-settings","features":{"networking":true},"login":true,"preferredVersions":{"php":"8.2","wp":"latest"},"steps":[{"step":"setSiteOptions","options":{"blogname":"Remote%20Data%20Blocks%20PR#${{ github.event.pull_request.number }}","blogdescription":"Explore%20the%20Remote%20Data%20Blocks%20plugin%20in%20a%20WordPress%20Playground"}},{"step":"defineWpConfigConsts","consts":{"USE_PLAYGROUND_CORS_PROXY":true}},{"step":"installPlugin","pluginData":{"caption":"Installing%20RDB","resource":"url","url":"https://wordpress-playground.atomicsites.blog/plugin-proxy.php?org=Automattic&repo=remote-data-blocks&workflow=Build%20Live%20Branch&artifact=remote-data-blocks-${{ github.event.pull_request.number }}&pr=${{ github.event.pull_request.number }}"},"options":{"activate":true,"targetFolderName":"remote-data-blocks"}}]}).