Skip to content

Add Gen UI Analytics Dashboard listing #264

Add Gen UI Analytics Dashboard listing

Add Gen UI Analytics Dashboard listing #264

name: Push PR to Submissions Realm
# Temporary review aid: mirrors each open PR's changed files into the shared
# staging submissions realm so reviewers can see the content running before
# merge. Push-only by design — the realm also holds PrCard instances and other
# PRs' pushes, so never sync with --delete. Decommission by deleting this file.
on:
pull_request:
types: [opened, synchronize, reopened]
concurrency:
group: submissions-push-${{ github.event.pull_request.number }}
cancel-in-progress: false
env:
SUBMISSIONS_REALM_URL: https://realms-staging.stack.cards/submissions/
jobs:
push:
name: Push to Submissions Realm
# Fork PRs have no access to secrets; skip rather than fail.
if: github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
env:
MATRIX_URL: https://matrix-staging.stack.cards
MATRIX_USERNAME: ${{ secrets.STAGING_SUBMISSIONBOT_MATRIX_USERNAME }}
MATRIX_PASSWORD: ${{ secrets.STAGING_SUBMISSIONBOT_MATRIX_PASSWORD }}
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
# HEAD is the PR merge commit; depth 2 brings in its parents, which
# is all the changed-files diff below needs.
fetch-depth: 2
- name: Setup Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: "24"
- name: Install Boxel CLI
run: npm install -g @cardstack/boxel-cli@latest
- name: Configure Boxel profile
run: |
if echo "$MATRIX_URL" | grep -q "boxel.ai"; then
DOMAIN="boxel.ai"
elif echo "$MATRIX_URL" | grep -q "stack.cards"; then
DOMAIN="stack.cards"
else
DOMAIN="localhost"
fi
boxel profile add \
--user "@${MATRIX_USERNAME}:${DOMAIN}" \
--password "${MATRIX_PASSWORD}" \
--matrix-url "${MATRIX_URL}"
- name: Stage this PR's changed files
# The realm is shared across open PRs, so pushing the whole tree would
# reset every file back to this PR's view of main, reverting other
# PRs' pushes. Stage only this PR's diff and push that. realm.json and
# index.json belong to the realm itself, and a stray sync manifest
# would make the CLI misclassify add-vs-update, so exclude all three.
run: |
STAGE="${RUNNER_TEMP}/push-stage"
mkdir -p "$STAGE"
# HEAD is the PR merge commit, whose first parent is the base branch
# tip, so this diff yields exactly the PR's changes. The list is
# saved so the PR comment reflects what was actually pushed.
git diff --name-only --diff-filter=d HEAD^1 HEAD \
-- . ':!realm.json' ':!index.json' ':!.boxel-sync.json' \
> "${RUNNER_TEMP}/pushed-files.txt"
while IFS= read -r f; do
mkdir -p "${STAGE}/$(dirname "$f")"
cp "$f" "${STAGE}/$f"
done < "${RUNNER_TEMP}/pushed-files.txt"
echo "Staged $(find "$STAGE" -type f | wc -l | tr -d ' ') file(s)"
- name: Push to submissions realm
run: |
echo "Target workspace: ${SUBMISSIONS_REALM_URL}"
echo "Commit: ${{ github.event.pull_request.head.sha }}"
boxel realm push "${RUNNER_TEMP}/push-stage" "${SUBMISSIONS_REALM_URL}" --force
- name: Compose PR comment
env:
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: |
COMMENT="${RUNNER_TEMP}/submissions-comment.md"
CHANGED=$(cat "${RUNNER_TEMP}/pushed-files.txt")
{
echo "## Staging Submissions Preview"
echo ""
echo "This PR's content is pushed to the staging submissions realm: **${SUBMISSIONS_REALM_URL}**"
echo ""
LISTINGS=$(echo "$CHANGED" | grep -E '/CardListing/[^/]+\.json$' || true)
if [ -n "$LISTINGS" ]; then
echo "Changed listings:"
while IFS= read -r f; do
echo "- ${SUBMISSIONS_REALM_URL}${f%.json}"
done <<< "$LISTINGS"
echo ""
fi
FOLDERS=$(echo "$CHANGED" | grep '/' | cut -d/ -f1 | sort -u)
if [ -n "$FOLDERS" ]; then
echo "Changed folders:"
while IFS= read -r d; do
echo "- \`${d}/\`"
done <<< "$FOLDERS"
echo ""
fi
echo "_Updated at $(date -u '+%Y-%m-%d %H:%M:%S') UTC for commit \`${HEAD_SHA::7}\`. Shared realm: only this PR's changed files are pushed; files touched by multiple PRs reflect whichever pushed last, and deleted files are not removed._"
} > "$COMMENT"
- name: Comment on PR
uses: marocchino/sticky-pull-request-comment@0ea0beb66eb9baf113663a64ec522f60e49231c0 # v3.0.4
with:
header: catalog-submissions-push
path: ${{ runner.temp }}/submissions-comment.md