Skip to content

Commit affe5c0

Browse files
authored
Merge changes from the private repository (#2226)
## Motivation for the change, related issues This PR merges the changes from a private Playground fork as [Automattic is resuming WordPress contributions](https://automattic.com/2025/05/29/returning-to-core/). **Let's merge this PR as is without squashing. These individual commits carry a lot of context.** ### A summary of changes Okay, I've merged the changelog entries into a single list and replaced the private PR links with their corresponding public commit links from the provided list. Here's the consolidated list: - Revert "[ php-wasm ] add Intl support (#150)". ([781d97b](781d97b711)) - Use the new SQLite driver. ([a7c1061](a7c1061ff2)) - [ php-wasm ] Add intl support. ([4382776](4382776eff)) - [ php-wasm ] Intl : Improve integration. ([8a01fac](8a01facea6)) - [ php-wasm ] add Intl support. ([8d11917](8d11917b81)) - [CLI] Enable users to automatically mount their current working directory into Playground. ([cb670ec](cb670ecbc4)) - [PHP-wasm Node] Fix Identifier '\_\_filename' has already been declared. ([fc24cb0](fc24cb0b39)) - [Website] Support data URLs in blueprint-url query parameter. ([5a2e706](5a2e706b34)) - Define `DB_NAME` constant when it's missing. ([35f7356](35f735676c)) - Support limiting files added to self-hosted packages. ([ef4144c](ef4144c858)) - Document mounting OPFS storage _after_ the boot. ([9cdb188](9cdb188e1c)) - QUERY_STRING should default to empty string. ([b104159](b104159738)) - Remove null steps that are added. ([cdf6290](cdf62903c8)) - [CLI] Fix package entry point path. ([481ee95](481ee95912)) - Add MySQL network calls to Asyncify tests. ([d613cd6](d613cd6a60)) - Format the plugin-proxy file. ([7bde598](7bde598a95)) - Plugin proxy: Allow all repos from WordPress, Automattic and Woocommerce organizations. ([0b998b2](0b998b2c1f)) - Remove unused dependencies. ([2a3d28e](2a3d28ee2e)) - [PHP-wasm Node] Add support for resolving wasm paths in Windows. ([8ba3c2c](8ba3c2c3f0)) - [PHP-wasm Node] Dynamically mount symlinks. ([f95d496](f95d4969d7)) - Fix changelog version order. ([a4fca31](a4fca315ec)) - Fix openssl library paths in php-wasm build. ([cb0ea95](cb0ea95105)) - Add private fork links to the changelog. ([811f48b](811f48ba1f)) - Allow public access to A8C Playground instance. ([486032d](486032d388)) - Make php-wasm and Playground CLI's fast to run with Node.js. ([6b09477](6b0947710d)) - Playground CLI: Add `skipSqliteSetup` flag for MySQL support. ([81db60b](81db60b80e)) - Prep the WP update workflows to be re-enabled. ([2bc3fae](2bc3fae6a7)) - Support building for additional remote origins. ([1ce2126](1ce2126ec1)) - Tweak Blueprint test string to match WP 6.8. ([f507a08](f507a08edc)) - Update Nx, Vite, and ESLint dependencies. ([1385984](13859842bd)) - Upgrade octokit to 3.1.2 to fix vulnerability. ([5cc7a3e](5cc7a3e7fc)) - Use Node as the Vitest environment. ([d304149](d3041499c8)) - Fix changelog workflow and backfill changelog entries from recent versions. ([f003f02](f003f024fe)) - Consider unexpected undefined symbols to be errors. ([fa41a9f](fa41a9f84c)) - Ignore ca-bundle created by @php-wasm/cli. ([f2a3ae8](f2a3ae889e)) - Support Node.js args to built-script executor. ([5a3551d](5a3551dcbd)) - Support quickly testing php-wasm CLI changes with bun. ([fea9e99](fea9e991a0)) - Update Emscripten version to 4.0.5. ([b38db76](b38db76163)) - Update Playground Node version to 20.9.0. ([b150e6e](b150e6e44d)) - Upgrade express to 4.21.2. ([9ff293b](9ff293bba2)) - [PHP-wasm] Use statfs from NODEFS in the Node version. ([716c70c](716c70c27d)) - Blueprint bundles. ([a88b704](a88b704f4e)) - CORS Proxy: fetch() with credentials: "include". ([db243a7](db243a74be)) - Exif support for PHP-wasm. ([db4c4fc](db4c4fc3fc)) - Remove Data Liberation PHP modules. ([a3fe1d0](a3fe1d04a5)) - Stop suppressing 64bit integer PHP warnings as 64bit longs are now suppoted. ([f5df251](f5df251129)) - [Blueprints] setSiteLanguage fetch translation package URL from WP.org. ([5593848](55938483a8)) - [Website] Drop the static <link rel="manifest"> tag and generate one in JavaScript instead. ([ace3224](ace3224198)) - 64bit integer support, drop PHP 7.0 and 7.1 support. ([6e5785b](6e5785b951)) - FS Journal: Handle renaming OPFS files via delete + create (instead of file.move()). ([cc69f49](cc69f497ff)) - GitHub: Cache node_modules per arch to avoid nx error. ([b0e5ac2](b0e5ac2a91)) - Merge from public Playground repo. ([1acd783](1acd783ee5)) - OPFS site creation: Use the same "is this directory a site?" check as the site list. ([27c1c39](27c1c39569)) - Stop adding source maps to offline assets list. ([af2a6dd](af2a6dd8e1)) - Support mobile access to private Playground instance. ([75ca755](75ca75572d)) - TLS->HTTP Proxy: Support outbound request body. ([75914a5](75914a5e35)) - TLS: Only use the server_name extension during server hello. ([0f66399](0f66399814)) - Website: Blueprints as PWAs with a dynamic manifest.json file. ([f3fc591](f3fc591c00)) - Website: Preserve the `mode` query arg when opening OPFS site. ([b12dc91](b12dc910a3)) - Fix php-wasm build error for WITH_SOURCEMAPS=yes. ([aa72e45](aa72e45d79)) - Fix php-wasm source map base. ([aa1e086](aa1e086765)) - Fix private website deployment workflow. ([2126101](21261013b1)) - Fix up private website deployment workflow after initial commit. ([1c166d9](1c166d96f3)) - Add WITH_DEBUG option for building php-wasm with DWARF debug info. ([6911327](6911327245)) - Add `janjakes` to GitHub workflows actors. ([8bab3a7](8bab3a7c10)) - Add a dedicated workflow for deploying private playground. ([9eba050](9eba050cc9)) - Add remote data blocks to the allowlist. ([e092d44](e092d448c9)) - Allow ashfame to run self-hosted package release workflow. ([3a258e1](3a258e1e6a)) - Allow deploying custom supported domains for CORS proxy. ([061de93](061de93ab0)) - CORS proxy: Make allowed origins configurable. ([0613543](06135433fe)) - Make further fixes for unreliable end-to-end tests. ([2657952](26579524ce)) - Move DNS polyfills to a PHP extension and add missing constants. ([756ea70](756ea70b8f)) - New playground CLI function interface. ([08d7a8e](08d7a8e3eb)) - Replace some hardcoded refs to playground.wordpress.net web app. ([256f65b](256f65b6b0)) - Restore safety condition for CORS proxy deployment workflow. ([0973e38](0973e3818b)) - Revert "Add the launch browser flag to CLI". ([980bbb1](980bbb1cc6)) - Revert "Support file URL resources in command line environment". ([c0815ce](c0815ce947)) - Schedule private deployment and use private environment. ([e3ec1d9](e3ec1d9dd2)) - Stop assuming CLI stdout is a TTY write stream. ([877321e](877321e3e1)) - Store WordPress site cookies in the browser instead of a custom Cookie Store. ([172d32e](172d32edcc)) - Support file URL resources in command line environment. ([b6d6ef6](b6d6ef63e7)) - Switch to relative paths in app manifest. ([3fd6bb1](3fd6bb198e)) - Switch to runner with more CPU and RAM. ([eaa6ce9](eaa6ce906e)) - Treat zip files as zip files regardless of file name. ([0140ef3](0140ef3d0f)) - Try more Playwright workers since we have a runner with more resources. ([5066fc8](5066fc8aee)) - Update private Playground instance to use dedicated CORS proxy. ([45495a2](45495a2787)) - Use rsync instead of scp in website deploy workflow. ([c2cd891](c2cd891808)) - Use specified SQLite version also for PHP < 7.4. ([469a7cc](469a7ccb5a)) - Fix workflow for deploying self-hosted packages. ([8542e79](8542e798cd)) - Add the launch browser flag to CLI. ([7bea6ec](7bea6ecb24)) - [Fix] Zip spec compliance for exported backup file. ([f894b48](f894b48175)) - Add missing node external to Playground CLI. ([36fece7](36fece7699)) - Add self-hosted package publishing. ([732a454](732a454ce1))
2 parents 7d8598c + 447a3a1 commit affe5c0

File tree

2,031 files changed

+86110
-544078
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,031 files changed

+86110
-544078
lines changed

.eslintignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ __pycache__
77
packages/playground/wordpress-builds/src/wordpress
88
packages/playground/wordpress-builds/public
99
packages/playground/sync/src/test/wp-*
10-
packages/playground/data-liberation/tests/fixtures
1110
packages/php-wasm/node/src/test/__test*
1211
*.timestamp-1678999213403.mjs
1312
.local

.eslintrc.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@
7474
"@typescript-eslint/no-empty-function": 0,
7575
"@typescript-eslint/no-unused-vars": "error",
7676
"no-constant-condition": 0,
77-
"playground-dev/avoid-wordpress-builds-dependency": "error"
77+
"playground-dev/avoid-wordpress-builds-dependency": "error",
78+
// Node.js type stripping requires explicit type imports.
79+
"@typescript-eslint/consistent-type-imports": "error"
7880
}
7981
},
8082
{

.gitattributes

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,16 @@ packages/playground/remote/src/wordpress linguist-generated=true -diff
1212
packages/playground/wordpress-builds/src/wordpress linguist-generated=true -diff
1313
packages/playground/wordpress-builds/src/public linguist-generated=true -diff
1414
packages/playground/blueprints/public/ linguist-generated=true
15+
16+
# Avoid large non-essential files in release archives
17+
packages/playground/wordpress-builds/public/**/* export-ignore
18+
packages/playground/wordpress-builds/src/wordpress/**/*.zip export-ignore
19+
packages/php-wasm/web/public/php/**/*.wasm export-ignore
20+
packages/php-wasm/node/**/*.wasm export-ignore
21+
packages/playground/website/playwright/**/* export-ignore
22+
**/test/**/* export-ignore
23+
**/tests/**/* export-ignore
24+
**/test-fixtures/**/* export-ignore
25+
#*.so.* export-ignore
26+
#*.a export-ignore
27+
packages/playground/website/demos/* export-ignore

.github/actions/prepare-playground/action.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ inputs:
55
type: string
66
required: true
77
description: 'Node.js version to use'
8-
default: '18'
8+
default: '20'
99

1010
runs:
1111
using: 'composite'
@@ -24,7 +24,7 @@ runs:
2424
with:
2525
# caching node_modules
2626
path: node_modules
27-
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('package-lock.json') }}
27+
key: ${{ runner.os }}-${{ runner.arch }}-build-${{ env.cache-name }}-${{ hashFiles('package-lock.json') }}
2828
restore-keys: |
2929
${{ runner.os }}-build-${{ env.cache-name }}-
3030
${{ runner.os }}-build-
@@ -39,3 +39,6 @@ runs:
3939
- name: Set NX_HEAD
4040
shell: bash
4141
run: echo "NX_HEAD=$(git rev-parse HEAD)" >> $GITHUB_ENV
42+
- name: Reset NX cache
43+
shell: bash
44+
run: npx nx reset

.github/workflows/build-website.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ jobs:
2222
github.actor == 'dmsnell' ||
2323
github.actor == 'bgrgicak' ||
2424
github.actor == 'brandonpayton' ||
25-
github.actor == 'zaerl'
25+
github.actor == 'zaerl' ||
26+
github.actor == 'janjakes'
2627
)
2728
2829
# Specify runner + deployment step

.github/workflows/ci.yml

Lines changed: 129 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -30,31 +30,62 @@ jobs:
3030
fail-fast: false
3131
matrix:
3232
include:
33-
- name: test-unit-asyncify (1/8)
34-
target: test-node
35-
- name: test-unit-asyncify (2/8)
33+
- name: test-unit-asyncify (1/14)
34+
target: test
35+
- name: test-unit-asyncify (2/14)
3636
target: test-php
37-
- name: test-unit-asyncify (3/8)
37+
- name: test-unit-asyncify (3/14)
3838
target: test-php-request-handler-files
39-
- name: test-unit-asyncify (4/8)
39+
- name: test-unit-asyncify (4/14)
4040
target: test-php-request-handler-requests
41-
- name: test-unit-asyncify (5/8)
42-
target: test-php-asyncify-file-get-contents
43-
- name: test-unit-asyncify (6/8)
44-
target: test-php-asyncify-fopen
45-
- name: test-unit-asyncify (7/8)
46-
target: test-php-asyncify-fsockopen
47-
- name: test-unit-asyncify (8/8)
48-
target: test-php-asyncify-gethostbyname
41+
- name: test-unit-asyncify (5/14)
42+
target: test-php-asyncify-file-get-contents-http
43+
- name: test-unit-asyncify (6/14)
44+
target: test-php-asyncify-file-get-contents-https
45+
- name: test-unit-asyncify (7/14)
46+
target: test-php-asyncify-fopen-http
47+
- name: test-unit-asyncify (8/14)
48+
target: test-php-asyncify-fopen-https
49+
- name: test-unit-asyncify (9/14)
50+
target: test-php-asyncify-fsockopen-http
51+
- name: test-unit-asyncify (10/14)
52+
target: test-php-asyncify-fsockopen-https
53+
- name: test-unit-asyncify (11/14)
54+
target: test-php-asyncify-gethostbyname-http
55+
- name: test-unit-asyncify (12/14)
56+
target: test-php-asyncify-gethostbyname-https
57+
- name: test-unit-asyncify (13/14)
58+
target: test-php-asyncify-mysqli-http
59+
- name: test-unit-asyncify (14/14)
60+
target: test-php-asyncify-mysqli-https
4961
name: ${{ matrix.name }}
62+
services:
63+
mysql:
64+
image: mysql:5.7
65+
env:
66+
MYSQL_DATABASE: test_db
67+
MYSQL_USER: user
68+
MYSQL_PASSWORD: password
69+
MYSQL_ROOT_PASSWORD: rootpassword
70+
ports:
71+
- 3306:3306
72+
options: >-
73+
--health-cmd="mysqladmin ping --silent"
74+
--health-interval=10s
75+
--health-timeout=5s
76+
--health-retries=3
5077
steps:
5178
- uses: actions/checkout@v4
5279
with:
5380
submodules: true
5481
- uses: ./.github/actions/prepare-playground
5582
with:
56-
node-version: 22
57-
- run: node --expose-gc node_modules/nx/bin/nx affected --target=${{ matrix.target }} --configuration=ci
83+
node-version: 20
84+
- run: node --expose-gc node_modules/nx/bin/nx affected --target=${{ matrix.target }}
85+
env:
86+
MYSQL_DATABASE: test_db
87+
MYSQL_USER: user
88+
MYSQL_PASSWORD: password
5889
# Most of these tests pass locally but the process is crashing
5990
# on the CI runner.
6091
#
@@ -150,6 +181,75 @@ jobs:
150181
uses: geekyeggo/delete-artifact@v5
151182
with:
152183
name: playwright-dist
184+
test-built-npm-packages:
185+
runs-on: ubuntu-latest
186+
needs: [lint-and-typecheck]
187+
steps:
188+
- uses: actions/checkout@v4
189+
with:
190+
submodules: true
191+
- uses: ./.github/actions/prepare-playground
192+
- name: Generate a mock version number (for releasing the packages in a local registry) and store it as a global variable
193+
run: |
194+
VERSION=$(date +%s)
195+
PORT=9934
196+
PACKAGE_BASE_URL=http://127.0.0.1:$PORT/$VERSION
197+
echo "VERSION=$VERSION" >> $GITHUB_ENV
198+
echo "PORT=$PORT" >> $GITHUB_ENV
199+
echo "PACKAGE_BASE_URL=$PACKAGE_BASE_URL" >> $GITHUB_ENV
200+
echo "PACKAGE_URL=$PACKAGE_BASE_URL/v$VERSION/@wp-playground-cli-$VERSION.tar.gz" >> $GITHUB_ENV
201+
echo "HOST_PATH=./dist/packages-for-self-hosting/http%3A%2F%2F127.0.0.1%3A$PORT%2F$VERSION" >> $GITHUB_ENV
202+
- name: Update package.json versions
203+
run: |
204+
VERSION=$(date +%s)
205+
for package in packages/*/*/package.json; do
206+
jq --arg version "$VERSION" '.version = $version' "$package" > "$package.tmp"
207+
mv "$package.tmp" "$package"
208+
done
209+
- name: Package repository
210+
run: |
211+
npx nx run-many --all --target=package-for-self-hosting -- --hostingBaseUrl="$PACKAGE_BASE_URL"
212+
- name: Install Bun
213+
uses: oven-sh/setup-bun@v2
214+
- name: Start a local node package registry server
215+
run: RUNNER_TRACKING_ID="" && (nohup bun ./packages/playground/cli/src/cli.ts server --port=$PORT --mount="$HOST_PATH:/wordpress/$VERSION" --quiet&)
216+
- name: Wait for the package server to be ready
217+
run: |
218+
for i in {1..60}; do
219+
curl_output=$(curl -v $PACKAGE_URL 2>&1)
220+
if [ $? -eq 0 ]; then
221+
break
222+
fi
223+
sleep 1
224+
done
225+
- name: Run integration tests in an ES Modules project
226+
run: |
227+
cd packages/playground/test-built-npm-packages/es-modules-and-vitest
228+
jq --arg package_url "$PACKAGE_URL" '.devDependencies["@wp-playground/cli"] = $package_url' package.json > package.json.tmp
229+
mv package.json.tmp package.json
230+
npm install
231+
INSTALLED_VERSION=$(npm ls @wp-playground/cli version --depth=0 | tail -n 2 | head -n 1 | cut -d ' ' -f 2)
232+
if [ "$INSTALLED_VERSION" != "@wp-playground/cli@$VERSION" ]; then
233+
echo "The installed version of @wp-playground/cli is not the same as the expected version."
234+
echo "Expected: $VERSION"
235+
echo "Installed: $INSTALLED_VERSION"
236+
exit 1
237+
fi
238+
npm run test
239+
- name: Run integration tests in a CommonJS project
240+
run: |
241+
cd packages/playground/test-built-npm-packages/commonjs-and-jest
242+
jq --arg package_url "$PACKAGE_URL" '.devDependencies["@wp-playground/cli"] = $package_url' package.json > package.json.tmp
243+
mv package.json.tmp package.json
244+
npm install
245+
INSTALLED_VERSION=$(npm ls @wp-playground/cli version --depth=0 | tail -n 2 | head -n 1 | cut -d ' ' -f 2)
246+
if [ "$INSTALLED_VERSION" != "@wp-playground/cli@$VERSION" ]; then
247+
echo "The installed version of @wp-playground/cli is not the same as the expected version."
248+
echo "Expected: $VERSION"
249+
echo "Installed: $INSTALLED_VERSION"
250+
exit 1
251+
fi
252+
npm run test
153253
154254
build:
155255
runs-on: ubuntu-latest
@@ -159,11 +259,21 @@ jobs:
159259
with:
160260
submodules: true
161261
- uses: ./.github/actions/prepare-playground
162-
- run: npx nx affected --target=build --parallel=3 --verbose
262+
- run: |
263+
if ADDITIONAL_REMOTE_ORIGINS=invalid-origin npx nx build playground-client; then
264+
echo "The Playground client build should have failed due to an invalid additional origin."
265+
echo "The build does not appear to be applying ADDITIONAL_REMOTE_ORIGINS."
266+
exit 1
267+
fi
268+
npx nx affected --target=build --parallel=3 --verbose
163269
164270
# Deploy documentation job
165271
deploy_docs:
166-
if: github.ref == 'refs/heads/trunk' && github.event_name == 'push'
272+
# Only deploy docs when pushing to the WordPress/wordpress-playground repository
273+
if: >
274+
github.repository == 'WordPress/wordpress-playground' &&
275+
github.ref == 'refs/heads/trunk' &&
276+
github.event_name == 'push'
167277
# Add a dependency to the build job
168278
needs: [test-unit-asyncify, test-e2e, build]
169279
name: 'Deploy doc site'
@@ -186,8 +296,8 @@ jobs:
186296
submodules: true
187297
- uses: ./.github/actions/prepare-playground
188298
- run: npm run build:docs
189-
- uses: actions/upload-pages-artifact@v3
299+
- uses: actions/upload-pages-artifact@v1
190300
with: { path: dist/docs/build }
191301
- name: Deploy to GitHub Pages
192302
id: deployment
193-
uses: actions/deploy-pages@v4
303+
uses: actions/deploy-pages@v2

.github/workflows/deploy-cors-proxy.yml

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,14 @@ jobs:
1919
github.actor == 'bgrgicak' ||
2020
github.actor == 'brandonpayton' ||
2121
github.actor == 'zaerl' ||
22-
github.actor == 'akirk'
22+
github.actor == 'akirk' ||
23+
github.actor == 'janjakes'
2324
)
2425
2526
# Specify runner + deployment step
2627
runs-on: ubuntu-latest
2728
environment:
28-
name: playground-wordpress-net-wp-cloud
29+
name: cors-proxy-wp-cloud
2930
steps:
3031
- uses: actions/checkout@v4
3132
with:
@@ -42,26 +43,54 @@ jobs:
4243
4344
- name: Deploy to CORS proxy server
4445
shell: bash
45-
# TODO: Use completely separate environments for website and CORS proxy deployments
46+
env:
47+
CUSTOM_SUPPORTED_ORIGINS_SPACE_SEPARATED: ${{ secrets.CUSTOM_SUPPORTED_ORIGINS_SPACE_SEPARATED }}
4648
run: |
4749
mkdir -p ~/.ssh
48-
echo "${{ secrets.DEPLOY_WEBSITE_TARGET_HOST_KEY }}" >> ~/.ssh/known_hosts
49-
echo "${{ secrets.DEPLOY_WEBSITE_PRIVATE_KEY }}" > ~/.ssh/id_ed25519
50+
echo "${{ secrets.DEPLOY_CORS_PROXY_TARGET_HOST_KEY }}" >> ~/.ssh/known_hosts
51+
echo "${{ secrets.DEPLOY_CORS_PROXY_PRIVATE_KEY }}" > ~/.ssh/id_ed25519
5052
chmod 0600 ~/.ssh/*
5153
5254
# CORS proxy files
5355
rsync --verbose --archive --compress -e "ssh -i ~/.ssh/id_ed25519" \
5456
--exclude 'tests/' --include '*/' --include '*.php' --exclude '*' \
5557
--delete --delete-excluded --prune-empty-dirs \
5658
packages/playground/php-cors-proxy/ \
57-
${{ secrets.DEPLOY_CORS_PROXY_TARGET_USER }}@${{ secrets.DEPLOY_WEBSITE_TARGET_HOST }}:'~/updated-proxy-files'
59+
${{ secrets.DEPLOY_CORS_PROXY_TARGET_USER }}@${{ secrets.DEPLOY_CORS_PROXY_TARGET_HOST }}:'~/updated-proxy-files'
5860
5961
# Host-specific deployment scripts and server config
6062
rsync --verbose --archive --compress -e "ssh -i ~/.ssh/id_ed25519" --delete \
6163
packages/playground/php-cors-proxy-deployment/ \
62-
${{ secrets.DEPLOY_CORS_PROXY_TARGET_USER }}@${{ secrets.DEPLOY_WEBSITE_TARGET_HOST }}:'~/cors-proxy-deployment'
64+
${{ secrets.DEPLOY_CORS_PROXY_TARGET_USER }}@${{ secrets.DEPLOY_CORS_PROXY_TARGET_HOST }}:'~/cors-proxy-deployment'
6365
6466
# Apply update
6567
ssh -i ~/.ssh/id_ed25519 \
66-
${{ secrets.DEPLOY_CORS_PROXY_TARGET_USER }}@${{ secrets.DEPLOY_WEBSITE_TARGET_HOST }} \
68+
${{ secrets.DEPLOY_CORS_PROXY_TARGET_USER }}@${{ secrets.DEPLOY_CORS_PROXY_TARGET_HOST }} \
6769
-tt -C '~/cors-proxy-deployment/apply-update.sh'
70+
71+
# If configured, support CORS responses for a custom list of origins
72+
if [[ -n "${CUSTOM_SUPPORTED_ORIGINS_SPACE_SEPARATED}" ]]; then
73+
CUSTOM_ORIGINS_PHP="<?php define('PLAYGROUND_CORS_PROXY_SUPPORTED_ORIGINS', array("
74+
75+
for origin in $CUSTOM_SUPPORTED_ORIGINS_SPACE_SEPARATED; do
76+
if ! (
77+
[[ $origin =~ ^https?://([a-zA-Z0-9-]+\.)*[a-zA-Z]{2,}$ ]] ||
78+
[[ $origin =~ ^https?://([0-9]{1,3}\.){3}[0-9]{1,3}$ ]] ||
79+
[[ $origin =~ ^https?://^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$ ]]
80+
); then
81+
echo "Unable to use CUSTOM_SUPPORTED_ORIGINS_SPACE_SEPARATED"
82+
echo "Invalid origin: '$origin'"
83+
exit -1;
84+
fi
85+
86+
echo "Adding custom supported origin: '$origin'"
87+
CUSTOM_ORIGINS_PHP+="'$origin', "
88+
done
89+
90+
CUSTOM_ORIGINS_PHP+='));'
91+
92+
echo "$CUSTOM_ORIGINS_PHP" > custom-redirects.php
93+
rsync -avz -e "ssh -i ~/.ssh/id_ed25519" \
94+
custom-redirects.php \
95+
${{ secrets.DEPLOY_CORS_PROXY_TARGET_USER }}@${{ secrets.DEPLOY_CORS_PROXY_TARGET_HOST }}:'~/htdocs/'
96+
fi

0 commit comments

Comments
 (0)