\(env.COMMIT)"])),
+ }
+ ' > "$tmp"
+ find result -name '*.html' -exec \
+ node scripts/insert_warning.mjs scripts/pr_preview_warning.html "$tmp" '{}' '+'
+ - name: Publish to gh-pages
+ uses: JamesIves/github-pages-deploy-action@v4
+ with:
+ branch: gh-pages
+ folder: result
+ target-folder: pr/${{ env.PR }}
+ - name: Determine gh-pages url
+ id: get-pages-url
+ run: |
+ gh_pages_url="https://$(printf '%s' "$GITHUB_REPOSITORY" \
+ | sed 's#/#.github.io/#; s#^tc39.github.io/#tc39.es/#')"
+ echo "url=$gh_pages_url" >> $GITHUB_OUTPUT
+ - name: Provide PR comment
+ uses: phulsechinmay/rewritable-pr-comment@v0.3.0
+ with:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ ISSUE_ID: ${{ env.PR }}
+ message: >
+ The rendered spec for this PR is available at
+ ${{ steps.get-pages-url.outputs.url }}/pr/${{ env.PR }}.
diff --git a/.github/workflows/render-pr.yml b/.github/workflows/render-pr.yml
new file mode 100644
index 0000000..fc7537e
--- /dev/null
+++ b/.github/workflows/render-pr.yml
@@ -0,0 +1,39 @@
+name: Render PR
+
+on: [pull_request]
+
+env:
+ # Must match ./publish-pr.yml
+ ARTIFACT_NAME: ${{ vars.ARTIFACT_NAME || 'result' }}
+
+jobs:
+ render:
+ runs-on: ubuntu-latest
+ if: ${{ github.event.pull_request }}
+ steps:
+ - uses: actions/checkout@v4
+ - name: '[node LTS] npm install'
+ uses: ljharb/actions/node/install@main
+ with:
+ node-version: lts/*
+ - run: npm run build
+ - name: Save PR data
+ env:
+ PR: ${{ github.event.number }}
+ run: echo "$PR $(git rev-parse --verify HEAD)" > build/pr-data.txt
+ - uses: actions/upload-artifact@v4
+ id: upload
+ if: ${{ !github.event.repository.fork }}
+ with:
+ name: ${{ env.ARTIFACT_NAME }}
+ path: build/
+ - name: Echo artifact ID
+ run: echo 'Artifact ID is ${{ steps.upload.outputs.artifact-id }}'
+ - name: Verify artifact discoverability
+ uses: actions/github-script@v7
+ with:
+ script: |
+ const { owner, repo } = context.repo;
+ const run_id = ${{ github.run_id }};
+ const listArtifactsResponse = await github.rest.actions.listWorkflowRunArtifacts({ owner, repo, run_id });
+ console.log(`artifacts for run id ${run_id}`, listArtifactsResponse?.data);
diff --git a/package.json b/package.json
index 438a1fa..e46c4c0 100644
--- a/package.json
+++ b/package.json
@@ -15,7 +15,10 @@
"license": "MIT",
"devDependencies": {
"@tc39/ecma262-biblio": "^2.1.2816",
- "ecmarkup": "^20.0.0"
+ "ecmarkup": "^20.0.0",
+ "jsdom": "^25.0.1",
+ "parse5-html-rewriting-stream": "^7.0.0",
+ "tmp": "^0.2.3"
},
"engines": {
"node": ">= 18"
diff --git a/scripts/insert_warning.mjs b/scripts/insert_warning.mjs
new file mode 100644
index 0000000..f493d78
--- /dev/null
+++ b/scripts/insert_warning.mjs
@@ -0,0 +1,141 @@
+import fs from 'fs';
+import { readFile, rename } from 'fs/promises';
+import pathlib from 'path';
+import { pipeline } from 'stream/promises';
+import { parseArgs } from 'util';
+import { JSDOM } from 'jsdom';
+import { RewritingStream } from 'parse5-html-rewriting-stream';
+import tmp from 'tmp';
+
+const { positionals: cliArgs } = parseArgs({
+ allowPositionals: true,
+ options: {},
+});
+if (cliArgs.length < 3) {
+ const self = pathlib.relative(process.cwd(), process.argv[1]);
+ console.error(`Usage: node ${self}