Skip to content

Conversation

@hanspagel
Copy link
Member

@hanspagel hanspagel commented Oct 9, 2025

Problem

Currently, we push the Scalar Galaxy example to the Registry on release, that’s fine. I’d like to see if we can have PR previews for the OpenAPI document, too.

Solution

This PR adds a new workflow, that looks for changes to @scalar/galaxy.

When there’s a change, it pushes the updated OpenAPI document to the Registry.

To avoid conflicts, it’s adding the branch to the version number.

Tasks

  • we need a way to not make the uploaded file the default right-away (--no-current doesn't seem to work), waiting for the next @scalar/cli release

Checklist

I've gone through the following:

  • I've added an explanation why this change is needed.
  • I've added a changeset (pnpm changeset).
  • I've added tests for the regression or new feature.
  • I've updated the documentation.

Note

Adds a CI workflow to publish/delete PR preview versions of Galaxy to Scalar Registry and updates the OpenAPI title to indicate PREVIEW.

  • CI/CD:
    • Add .github/workflows/scalar-registry-preview.yml to publish PR previews of @scalar/galaxy to Scalar Registry on opened/synchronize, including version suffix with branch; delete preview on closed.
    • Builds @scalar/galaxy only when packages/galaxy/** changes, logs in via SCALAR_API_KEY, and publishes packages/galaxy/dist/latest.yaml with generated preview version.
  • OpenAPI Docs:
    • Update packages/galaxy/src/documents/3.1.yaml info.title to Scalar Galaxy (PREVIEW).

Written by Cursor Bugbot for commit 9fa7895. This will update automatically on new commits. Configure here.

@hanspagel hanspagel self-assigned this Oct 9, 2025
@changeset-bot
Copy link

changeset-bot bot commented Oct 9, 2025

⚠️ No Changeset found

Latest commit: 8ccb853

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

cursor[bot]

This comment was marked as outdated.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 9, 2025

Scalar Components Snapshot Test Results

passed  152 passed

Details

report  Open report ↗︎
stats  152 tests across 19 suites
duration  46 seconds
commit  8ccb853

@github-actions
Copy link
Contributor

github-actions bot commented Oct 9, 2025

@github-actions
Copy link
Contributor

github-actions bot commented Oct 9, 2025

@github-actions
Copy link
Contributor

github-actions bot commented Oct 9, 2025

Scalar CDN Snapshot Diff Results

Details

report  Open report ↗︎
stats  0 tests across 0 suites
duration  unknown
commit  8ccb853
info  These tests are non-blocking and will not prevent merging of your PR.

Important

These tests detect visual differences between the current PR and the latest CDN build which means they may be affected by other changes in main that haven't been released yet.

They can help determine if the changes in the PR are causing any unexpected visual regressions but may be less helpful in isolating the exact cause. For more details see the readme.

Copy link
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Unconditional Preview Deletion Causes API Overhead

The delete-preview job attempts to delete a preview version without first checking if galaxy files were modified in the PR. This can lead to unnecessary API calls and potential workflow failures when no preview was ever published.

.github/workflows/scalar-registry-preview.yml#L56-L81

delete-preview:
if: github.event.action == 'closed'
runs-on: blacksmith-4vcpu-ubuntu-2204
timeout-minutes: 10
strategy:
matrix:
node-version: [22]
steps:
- name: Checkout repository
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
- name: Extract version and generate preview version
working-directory: packages/galaxy
run: |
VERSION=$(node -p "require('./package.json').version")
BRANCH_NAME=$(echo "${{ github.head_ref }}" | sed 's/[^a-zA-Z0-9-]/-/g')
PREVIEW_VERSION="${VERSION}-${BRANCH_NAME}"
echo "PREVIEW_VERSION=$PREVIEW_VERSION" >> $GITHUB_ENV
- name: Login to Scalar Registry
run: npx @scalar/cli@latest auth login --token ${{ secrets.SCALAR_API_KEY }}
- name: Delete preview version from Scalar Registry
run: npx @scalar/cli@latest registry delete --namespace scalar --slug galaxy --version ${{ env.PREVIEW_VERSION }}

Fix in Cursor Fix in Web


Comment on lines +58 to +94
if: github.event.action == 'closed'
runs-on: blacksmith-4vcpu-ubuntu-2204
timeout-minutes: 10
strategy:
matrix:
node-version: [22]

steps:
- name: Checkout repository
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5

- name: Extract version and generate preview version
working-directory: packages/galaxy
run: |
VERSION=$(node -p "require('./package.json').version")
BRANCH_NAME=$(echo "${{ github.head_ref }}" | sed 's/[^a-zA-Z0-9-]/-/g')
PREVIEW_VERSION="${VERSION}-${BRANCH_NAME}"
echo "PREVIEW_VERSION=$PREVIEW_VERSION" >> $GITHUB_ENV

- name: Login to Scalar Registry
run: npx @scalar/cli@latest auth login --token ${{ secrets.SCALAR_API_KEY }}

- name: Delete preview version from Scalar Registry
run: npx @scalar/cli@latest registry delete --namespace scalar --slug galaxy --version ${{ env.PREVIEW_VERSION }}

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 6 days ago

The fix is to add a permissions block to the delete-preview job within the .github/workflows/scalar-registry-preview.yml file. According to the CodeQL recommendation and the intended actions in delete-preview (no writing to the repository, only Scalar Registry management via CLI), the safest minimal permissions block is:

permissions:
  contents: read

This should be inserted at the same level as (and directly after) timeout-minutes: 10 for the delete-preview job, mirroring how permissions is set for publish-update-preview. No other changes are needed.


Suggested changeset 1
.github/workflows/scalar-registry-preview.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/scalar-registry-preview.yml b/.github/workflows/scalar-registry-preview.yml
--- a/.github/workflows/scalar-registry-preview.yml
+++ b/.github/workflows/scalar-registry-preview.yml
@@ -71,6 +71,8 @@
     if: github.event.action == 'closed'
     runs-on: blacksmith-4vcpu-ubuntu-2204
     timeout-minutes: 10
+    permissions:
+      contents: read
     strategy:
       matrix:
         node-version: [22]
EOF
@@ -71,6 +71,8 @@
if: github.event.action == 'closed'
runs-on: blacksmith-4vcpu-ubuntu-2204
timeout-minutes: 10
permissions:
contents: read
strategy:
matrix:
node-version: [22]
Copilot is powered by AI and may make mistakes. Always verify output.
@hanspagel hanspagel marked this pull request as draft October 9, 2025 09:53
This commit introduces a new GitHub Actions workflow for managing preview versions of the @scalar/galaxy package. The workflow triggers on pull request events, allowing for the automatic building, versioning, and publishing of preview versions to the Scalar Registry. Additionally, it includes a step to delete the preview version when the pull request is closed.
This commit modifies the Scalar Registry Preview workflow to ensure that the Scalar CLI commands use the latest version by appending `@latest` to the CLI commands for login and publish operations. This change enhances compatibility and ensures that the most recent features and fixes are utilized during the workflow execution.
@github-actions
Copy link
Contributor

@github-actions
Copy link
Contributor

Scalar References End to End Test Results

passed  61 passed

Details

report  Open report ↗︎
stats  61 tests across 28 suites
duration  17.7 seconds
commit  8ccb853

Important

These tests include snapshots that may need to be updated if there are intentional changes to the UI components. To update the snapshots run pnpm test:e2e:update in packages/api-reference and commit the changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants