Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 81 additions & 0 deletions .github/workflows/deploy-workers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Deploy Workers

on: [push, workflow_dispatch]

permissions:
contents: read
deployments: write

concurrency:
group: deploy-workers-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/dev' }}

jobs:
checks:
uses: ./.github/workflows/checks.yml

deploy:
name: Deploy SkyCrypt
needs: checks
runs-on: ubuntu-latest
environment:
name: ${{ github.ref == 'refs/heads/dev' && 'cloudflare-production' || 'cloudflare-development' }}
deployment: false
env:
CLOUDFLARE_ENV: ${{ vars.CLOUDFLARE_ENV }}

steps:
- name: Checkout
uses: actions/checkout@v7

- name: Require Wrangler environment
if: vars.CLOUDFLARE_ENV == ''
run: |
echo "::error::Set CLOUDFLARE_ENV in the selected GitHub environment."
exit 1

- name: Install dependencies
uses: ./.github/actions/pnpm-install

- name: Prepare build environment
run: cp .env.example .env

- name: Build
run: pnpm build
env:
PUBLIC_COMMIT_HASH: ${{ github.sha }}
PUBLIC_SERVER_API_URL: https://sky.shiiyu.moe/api/
PUBLIC_API_URL: https://sky.shiiyu.moe/api/
SERVER_API_TOKEN: ${{ secrets.SERVER_API_TOKEN }}

- name: Validate Worker bundle
run: pnpm exec wrangler deploy --dry-run --no-x-provision --env "$CLOUDFLARE_ENV"

- name: Get preview alias
id: ref
if: github.ref != 'refs/heads/dev'
run: echo "ref_name=${GITHUB_REF_NAME//[^a-zA-Z0-9-]/-}" >> "$GITHUB_OUTPUT"

- name: Initialize Preview Worker
if: github.ref != 'refs/heads/dev'
run: |
if pnpm exec wrangler versions list --env "$CLOUDFLARE_ENV" --json > "$RUNNER_TEMP/worker-versions.json" 2> "$RUNNER_TEMP/worker-versions-error.log"; then
exit 0
fi
if ! grep -Fq '[code: 10007]' "$RUNNER_TEMP/worker-versions-error.log"; then
cat "$RUNNER_TEMP/worker-versions-error.log" >&2
exit 1
fi
pnpm exec wrangler deploy --no-x-provision --env "$CLOUDFLARE_ENV"
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}

- name: Deploy
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
gitHubToken: ${{ github.token }}
environment: ${{ vars.CLOUDFLARE_ENV }}
command: ${{ github.ref == 'refs/heads/dev' && 'deploy --no-x-provision' || format('versions upload --preview-alias {0}', steps.ref.outputs.ref_name) }}
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,24 @@
> git push origin dev --force-with-lease
> ```

## Lunar Client Workers deployment

`.github/workflows/deploy-workers.yml` runs the existing lint, Svelte/TypeScript, and test checks before building and deploying this fork. `dev` selects the `cloudflare-production` GitHub environment; other branches select `cloudflare-development` and upload a preview version with a branch alias. A missing development Worker is initialized before its first preview upload.

Each GitHub environment must supply the `CLOUDFLARE_ACCOUNT_ID` and `CLOUDFLARE_API_TOKEN` secrets and the `CLOUDFLARE_ENV` variable (`production` or `development`). Restrict `cloudflare-production` to the `dev` branch. Account IDs come from those secrets, not Wrangler files. Both accounts use the Worker name `skycrypt-embed`; production owns `skycrypt-embed.lunarclient.com`, while development has no custom domain. Both environments retain the existing SkyCrypt API URLs.

Before enabling this workflow, provision the GitHub environments and account credentials, configure any required runtime secrets in the destination accounts, and disable the old Workers Builds integration so it does not deploy alongside GitHub Actions. The destination production account must contain the `lunarclient.com` zone. Deployments use `--no-x-provision` and no longer bind the old shared-account observability Tail Worker.

Local validation without deployment:

```sh
pnpm install --frozen-lockfile
cp .env.example .env
CLOUDFLARE_ENV=development PUBLIC_API_URL=https://sky.shiiyu.moe/api/ PUBLIC_SERVER_API_URL=https://sky.shiiyu.moe/api/ pnpm build
pnpm exec wrangler deploy --dry-run --no-x-provision --env development
pnpm exec wrangler deploy --dry-run --no-x-provision --env production
```

<p align="center">
<picture>
<source media="(prefers-color-scheme: light)" srcset="static/img/logo_black.avif">
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
"vite": "^8.2.2",
"vitest": "^4.1.11",
"vitest-browser-svelte": "^3.0.0",
"wrangler": "4.127.1",
"zod": "^4.4.3"
},
"simple-git-hooks": {
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 14 additions & 14 deletions src/context/preferences.svelte.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ describe("PreferencesContext Tests", () => {

untrack(() => {
expect(prefs.sectionOrder).toHaveLength(sections.length);
expect(prefs.performanceMode).toBe(false);
expect(prefs.performanceMode).toBe(true);
expect(prefs.keybind).toBe("/");
expect(prefs.showGlint).toBe(true);
expect(prefs.showGlint).toBe(false);
expect(prefs.rainbowEnchantments).toBe(false);
expect(prefs.mctooltip).toBe(false);
});
Expand Down Expand Up @@ -300,12 +300,12 @@ describe("PreferencesContext Tests", () => {

untrack(() => {
const before = prefs.performanceMode;
prefs.performanceMode = true;
prefs.performanceMode = false;
flushSync();
const after = prefs.performanceMode;

expect(before).toBe(false);
expect(after).toBe(true);
expect(before).toBe(true);
expect(after).toBe(false);
});
});

Expand Down Expand Up @@ -336,12 +336,12 @@ describe("PreferencesContext Tests", () => {

untrack(() => {
const before = prefs.showGlint;
prefs.showGlint = false;
prefs.showGlint = true;
flushSync();
const after = prefs.showGlint;

expect(before).toBe(true);
expect(after).toBe(false);
expect(before).toBe(false);
expect(after).toBe(true);
});
});

Expand Down Expand Up @@ -470,15 +470,15 @@ describe("PreferencesContext Tests", () => {
});

describe("performanceMode document.dataset", () => {
it("sets document.documentElement.dataset.performance to 'false' by default", ({ expect }) => {
it("sets document.documentElement.dataset.performance to 'true' by default", ({ expect }) => {
const cleanup = $effect.root(() => {
const prefs = new PreferencesContext();

untrack(() => {
flushSync();

expect(prefs.performanceMode).toBe(false);
expect(document.documentElement.dataset.performance).toBe("false");
expect(prefs.performanceMode).toBe(true);
expect(document.documentElement.dataset.performance).toBe("true");
});
});

Expand Down Expand Up @@ -744,9 +744,9 @@ describe("PreferencesContext Tests", () => {

untrack(() => {
flushSync();
expect(prefs.performanceMode).toBe(false);
expect(prefs.performanceMode).toBe(true);
expect(prefs.keybind).toBe("/");
expect(prefs.showGlint).toBe(true);
expect(prefs.showGlint).toBe(false);
expect(prefs.rainbowEnchantments).toBe(false);
});
});
Expand Down Expand Up @@ -791,7 +791,7 @@ describe("PreferencesContext Tests", () => {

expect(prefs.performanceMode).toBe(true);
expect(prefs.keybind).toBe("custom");
expect(prefs.showGlint).toBe(true);
expect(prefs.showGlint).toBe(false);
});
});

Expand Down
38 changes: 25 additions & 13 deletions wrangler.jsonc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "skycrypt-embed-lunarclient-com",
"name": "skycrypt-embed",
"main": ".svelte-kit/cloudflare/_worker.js",
"compatibility_date": "2026-01-27",
"compatibility_flags": ["nodejs_compat"],
Expand All @@ -9,13 +9,7 @@
"binding": "ASSETS",
"directory": ".svelte-kit/cloudflare"
},
"routes": [
{
"pattern": "skycrypt-embed.lunarclient.com",
"custom_domain": true
}
],
// Persist observability in Cloudflare and forward invocations to the central Tail Worker.
// Persist observability in the selected Cloudflare account.
"observability": {
"enabled": true,
"logs": {
Expand All @@ -32,13 +26,31 @@
"persist": true
}
},
"tail_consumers": [
{
"service": "moonsworth-workers-observability"
}
],
"vars": {
"PUBLIC_SERVER_API_URL": "https://sky.shiiyu.moe/api/",
"PUBLIC_API_URL": "https://sky.shiiyu.moe/api/"
},
"env": {
"production": {
"name": "skycrypt-embed",
"routes": [
{
"pattern": "skycrypt-embed.lunarclient.com",
"custom_domain": true
}
],
"vars": {
"PUBLIC_SERVER_API_URL": "https://sky.shiiyu.moe/api/",
"PUBLIC_API_URL": "https://sky.shiiyu.moe/api/"
}
},
"development": {
"name": "skycrypt-embed",
"routes": [],
"vars": {
"PUBLIC_SERVER_API_URL": "https://sky.shiiyu.moe/api/",
"PUBLIC_API_URL": "https://sky.shiiyu.moe/api/"
}
}
}
}
Loading