-
Notifications
You must be signed in to change notification settings - Fork 125
67 lines (59 loc) · 1.99 KB
/
Copy pathpr-playground-preview.yml
File metadata and controls
67 lines (59 loc) · 1.99 KB
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
name: PR Playground Preview Build
# Builds a Plugin Check zip for every pull request. A separate workflow_run
# publisher exposes the artifact and posts the Playground preview button, so
# forked PRs can be supported without running untrusted PR code with write
# permissions.
#
# References:
# - https://github.com/WordPress/action-wp-playground-pr-preview/tree/v2
# - https://wordpress.github.io/wordpress-playground/guides/github-action-pr-preview/
on:
pull_request:
types:
- opened
- synchronize
- reopened
- edited
permissions:
contents: read
jobs:
build:
name: Build Playground preview artifact
runs-on: ubuntu-latest
steps:
- name: Checkout PR head
uses: actions/checkout@v7
with:
# Untrusted code: never persist credentials.
persist-credentials: false
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
tools: composer
coverage: none
- name: Install production Composer dependencies
# The PR controls this whole job, so --no-scripts is not a boundary;
# the read-only token and the publisher's artifact checks are.
run: composer install --no-dev --optimize-autoloader --no-interaction --no-progress --no-scripts
- name: Build plugin zip honouring .distignore
env:
PLUGIN_SLUG: plugin-check
run: |
mkdir -p "build/${PLUGIN_SLUG}"
rsync -a --delete \
--exclude-from='.distignore' \
--exclude='.git' \
--exclude='.github' \
--exclude='build' \
./ "build/${PLUGIN_SLUG}/"
cd build
zip -qr "${PLUGIN_SLUG}.zip" "${PLUGIN_SLUG}"
ls -lh "${PLUGIN_SLUG}.zip"
- name: Upload plugin zip artifact
uses: actions/upload-artifact@v7
with:
name: plugin-check-zip
path: build/plugin-check.zip
if-no-files-found: error
retention-days: 5