Skip to content

build(deps-dev): bump fast-xml-parser from 4.5.6 to 4.5.7 #169

build(deps-dev): bump fast-xml-parser from 4.5.6 to 4.5.7

build(deps-dev): bump fast-xml-parser from 4.5.6 to 4.5.7 #169

name: Playground preview
# Builds the app (WITHOUT the editor) into a ZIP the Nextcloud Playground
# installs in the browser via the blueprint `installApp` step. The eXeLearning
# static editor is NOT baked into this zip — the blueprint overlays it at boot
# with an `unzip` step that pulls the shared upstream editor release (the same
# artifact the Moodle/WP playgrounds use), keeping this preview zip lean.
# Production releases (release.yml / auto-release.yml) still bake the editor in.
#
# - push to main -> refresh the rolling `playground` prerelease asset
# (exelearning.zip) that blueprint.json points at, so the
# README badge always boots the latest main.
# - pull_request -> publish a per-PR prerelease (playground-pr-<N>) and post
# a one-click playground link as a sticky PR comment.
# - PR closed -> delete that per-PR prerelease and its tag.
on:
push:
branches: [main]
pull_request:
types: [opened, synchronize, reopened, closed]
concurrency:
group: playground-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
permissions:
contents: write
pull-requests: write
env:
PLAYGROUND_URL: https://ateeducacion.github.io/nextcloud-playground/
jobs:
build:
# Build on push to main, and on open/sync/reopen of PRs from this repo.
# Fork PRs run with a read-only token (no release write), so skip them.
if: >-
github.event_name == 'push' ||
(github.event.action != 'closed' &&
github.event.pull_request.head.repo.full_name == github.repository)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
- name: Set up Node.js
uses: actions/setup-node@v7
with:
node-version: 22
cache: npm
- name: Install dependencies
run: npm ci
- name: Resolve preview identity
id: id
run: |
set -euo pipefail
if [ "${{ github.event_name }}" = "push" ]; then
echo "tag=playground" >> "$GITHUB_OUTPUT"
echo "version=playground" >> "$GITHUB_OUTPUT"
else
echo "tag=playground-pr-${{ github.event.pull_request.number }}" >> "$GITHUB_OUTPUT"
echo "version=pr-${{ github.event.pull_request.number }}" >> "$GITHUB_OUTPUT"
fi
# The editor is overlaid by the blueprint at boot (not baked into this
# zip), pinned to .editor-version and kept in sync with the upstream tag by
# auto-release.yml. Read it here so the PR comment reports the version the
# preview actually loads.
- name: Resolve eXeLearning editor version
id: editor
run: |
set -euo pipefail
REF=$(tr -d '[:space:]' < .editor-version)
echo "ref=$REF" >> "$GITHUB_OUTPUT"
echo "eXeLearning editor (overlaid at boot): $REF"
- name: Build the playground ZIP
run: |
set -euo pipefail
make package-zip PACKAGE_VERSION=${{ steps.id.outputs.version }}
cp "build/artifacts/exelearning-${{ steps.id.outputs.version }}.zip" exelearning.zip
ls -lh exelearning.zip
- name: Publish exelearning.zip to the preview release
uses: softprops/action-gh-release@v3
with:
tag_name: ${{ steps.id.outputs.tag }}
name: ${{ steps.id.outputs.tag }}
prerelease: true
make_latest: false
files: exelearning.zip
fail_on_unmatched_files: true
body: >
Automated Nextcloud Playground preview build (not a real release).
Installed in the browser via the blueprint `installApp` step.
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Inline the blueprint (pointed at this PR's asset) as URL-safe base64 in
# ?blueprint= so we don't have to host a per-PR blueprint file. URLSearchParams
# turns '+' into a space, so '+/' must become '-_' and padding is dropped.
# The asset is fetched through the shared CORS proxy because GitHub release
# downloads are served from Azure Blob without Access-Control-Allow-Origin,
# which a cross-origin browser fetch from the playground would reject.
- name: Build PR playground link
if: github.event_name == 'pull_request'
id: link
run: |
set -euo pipefail
asset="https://github-proxy.exelearning.dev/?repo=${{ github.repository }}&release=${{ steps.id.outputs.tag }}&asset=exelearning.zip"
jq --arg url "$asset" '(.steps[] | select(.step == "installApp")).url = $url' blueprint.json > blueprint.pr.json
# Sample fixtures are referenced from raw main; point them at this PR's
# commit so the preview reflects fixtures added/changed on the branch.
sed -i "s#/nextcloud-exelearning/main/tests/fixtures#/nextcloud-exelearning/${{ github.event.pull_request.head.sha }}/tests/fixtures#g" blueprint.pr.json
b64=$(base64 -w0 blueprint.pr.json | tr '+/' '-_' | tr -d '=')
echo "url=${PLAYGROUND_URL}?blueprint=${b64}" >> "$GITHUB_OUTPUT"
- name: Upsert PR comment
if: github.event_name == 'pull_request'
uses: actions/github-script@v9
env:
PREVIEW_URL: ${{ steps.link.outputs.url }}
PREVIEW_EDITOR: ${{ steps.editor.outputs.ref }}
with:
script: |
const marker = '<!-- playground-preview -->';
const url = process.env.PREVIEW_URL;
const editor = process.env.PREVIEW_EDITOR;
const button = 'https://raw.githubusercontent.com/ateeducacion/nextcloud-playground/refs/heads/main/assets/playground-preview-button.svg';
const body = [
marker,
'### Preview this PR in the Nextcloud Playground',
'',
`<a href="${url}" target="_blank" rel="noopener noreferrer"><img src="${button}" alt="Open this PR in the Nextcloud Playground" width="224"></a>`,
'',
"A fresh Nextcloud boots in your browser with this branch's " +
'`exelearning` app installed and enabled (log in as `admin` / `admin`). ' +
'Two sample `.elpx` are seeded under `exelearning-samples/` in Files — ' +
'click one to open the viewer.',
'',
`eXeLearning editor: \`${editor}\` (overlaid at boot from the upstream release).`,
].join('\n');
const { owner, repo } = context.repo;
const issue_number = context.payload.pull_request.number;
const comments = await github.paginate(github.rest.issues.listComments, {
owner, repo, issue_number,
});
const existing = comments.find((c) => c.body && c.body.includes(marker));
if (existing) {
await github.rest.issues.updateComment({ owner, repo, comment_id: existing.id, body });
} else {
await github.rest.issues.createComment({ owner, repo, issue_number, body });
}
cleanup:
if: >-
github.event_name == 'pull_request' &&
github.event.action == 'closed' &&
github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Delete the per-PR preview release and tag
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
tag="playground-pr-${{ github.event.pull_request.number }}"
gh release delete "$tag" --cleanup-tag --yes || echo "No release $tag to delete."