Skip to content

Commit d53c8c5

Browse files
authored
Isolate playground builds from deployment credentials (#27839)
The playground release jobs run `npm run check` and the builds on the runner that later receives `CF_API_TOKEN`. Move those commands into unprivileged jobs and pass named, digest-verified static artifacts to fresh `release-playground` jobs. The publishers reject symlinks, special files, and Pages server-code entrypoints before deployment. This isolates the playground build tools; it does not remove the publisher's Wrangler dependency. Locking that tooling is handled separately in #27838. Related: astral-sh/ruff-vscode#1152 and astral-sh/ty-vscode#526 reduce the dependency trees installed by the marketplace publishers. --------- Co-authored-by: zaniebot <[email protected]>
1 parent cab001e commit d53c8c5

2 files changed

Lines changed: 92 additions & 8 deletions

File tree

‎.github/workflows/publish-playground.yml‎

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,8 @@ env:
2424
permissions: {}
2525

2626
jobs:
27-
publish:
27+
build:
2828
runs-on: ubuntu-latest
29-
environment: release-playground
30-
env:
31-
CF_API_TOKEN_EXISTS: ${{ secrets.CF_API_TOKEN != '' }}
3229
steps:
3330
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
3431
with:
@@ -49,6 +46,49 @@ jobs:
4946
- name: "Build Ruff playground"
5047
run: npm run build --workspace ruff-playground
5148
working-directory: playground
49+
- name: "Upload Ruff playground"
50+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
51+
with:
52+
name: ruff-playground-dist
53+
path: playground/ruff/dist
54+
if-no-files-found: error
55+
retention-days: 1
56+
57+
publish:
58+
needs: build
59+
runs-on: ubuntu-latest
60+
environment: release-playground
61+
env:
62+
CF_API_TOKEN_EXISTS: ${{ secrets.CF_API_TOKEN != '' }}
63+
steps:
64+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
65+
with:
66+
persist-credentials: false
67+
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
68+
with:
69+
node-version: 24.19.0
70+
package-manager-cache: false
71+
- name: "Download Ruff playground"
72+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
73+
with:
74+
name: ruff-playground-dist
75+
path: playground/ruff/dist
76+
digest-mismatch: error
77+
- name: "Verify static playground assets"
78+
run: |
79+
# The build runs without deployment credentials, but its output may
80+
# still be compromised. Check for missing required assets, and reject
81+
# links and special files before the publisher consumes the artifact.
82+
# Wrangler can deploy `_worker.js` in the output or `functions/` in its
83+
# working directory as server-side Pages code, so reject both.
84+
# These checks do not establish that the generated HTML or JavaScript is safe.
85+
test -f playground/ruff/dist/index.html
86+
test ! -e playground/ruff/dist/_worker.js
87+
test ! -e functions
88+
if [[ -n "$(find playground/ruff/dist ! -type f ! -type d -print -quit)" ]]; then
89+
echo "Playground artifacts must contain only regular files and directories"
90+
exit 1
91+
fi
5292
- name: "Install deployment dependencies"
5393
if: ${{ env.CF_API_TOKEN_EXISTS == 'true' }}
5494
run: npm ci --ignore-scripts

‎.github/workflows/publish-ty-playground.yml‎

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,8 @@ env:
2727
RUSTUP_MAX_RETRIES: 10
2828

2929
jobs:
30-
publish:
30+
build:
3131
runs-on: ubuntu-latest
32-
environment: release-playground
33-
env:
34-
CF_API_TOKEN_EXISTS: ${{ secrets.CF_API_TOKEN != '' }}
3532
steps:
3633
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
3734
with:
@@ -59,6 +56,53 @@ jobs:
5956
test -f ty/dist/assets/pyodide-lock.json
6057
test -f ty/dist/assets/python_stdlib.zip
6158
working-directory: playground
59+
- name: "Upload ty playground"
60+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
61+
with:
62+
name: ty-playground-dist
63+
path: playground/ty/dist
64+
if-no-files-found: error
65+
retention-days: 1
66+
67+
publish:
68+
needs: build
69+
runs-on: ubuntu-latest
70+
environment: release-playground
71+
env:
72+
CF_API_TOKEN_EXISTS: ${{ secrets.CF_API_TOKEN != '' }}
73+
steps:
74+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
75+
with:
76+
persist-credentials: false
77+
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
78+
with:
79+
node-version: 24.19.0
80+
package-manager-cache: false
81+
- name: "Download ty playground"
82+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
83+
with:
84+
name: ty-playground-dist
85+
path: playground/ty/dist
86+
digest-mismatch: error
87+
- name: "Verify static playground assets"
88+
run: |
89+
# The build runs without deployment credentials, but its output may
90+
# still be compromised. Check for missing required assets, and reject
91+
# links and special files before the publisher consumes the artifact.
92+
# Wrangler can deploy `_worker.js` in the output or `functions/` in its
93+
# working directory as server-side Pages code, so reject both.
94+
# These checks do not establish that the generated HTML or JavaScript is safe.
95+
test -f playground/ty/dist/index.html
96+
test -f playground/ty/dist/assets/pyodide.asm.mjs
97+
test -f playground/ty/dist/assets/pyodide.asm.wasm
98+
test -f playground/ty/dist/assets/pyodide-lock.json
99+
test -f playground/ty/dist/assets/python_stdlib.zip
100+
test ! -e playground/ty/dist/_worker.js
101+
test ! -e functions
102+
if [[ -n "$(find playground/ty/dist ! -type f ! -type d -print -quit)" ]]; then
103+
echo "Playground artifacts must contain only regular files and directories"
104+
exit 1
105+
fi
62106
- name: "Install deployment dependencies"
63107
if: ${{ env.CF_API_TOKEN_EXISTS == 'true' }}
64108
run: npm ci --ignore-scripts

0 commit comments

Comments
 (0)