Skip to content

Commit 6b09e91

Browse files
authored
build: Release 29 04 26.staging (#5742)
1 parent cc45b28 commit 6b09e91

50 files changed

Lines changed: 735 additions & 101 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/actions/vercel/action.yaml

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,12 @@ inputs:
1818
description: "Sha"
1919
required: true
2020
environment:
21-
description: "Sha"
21+
description: "Alias environment"
2222
required: true
23+
production-staged:
24+
description: "Create a production deployment without assigning production domains"
25+
required: false
26+
default: "false"
2327
PUBLIC_COLLAB_RELAY_URL:
2428
description: "Public collaboration relay URL injected into the builder bundle"
2529
required: false
@@ -79,9 +83,14 @@ runs:
7983
run: |
8084
export GITHUB_SHA=${{ inputs.sha }}
8185
export GITHUB_REF_NAME=${{ inputs.ref-name }}
82-
export PUBLIC_COLLAB_RELAY_URL=${{ inputs.PUBLIC_COLLAB_RELAY_URL }}
8386
84-
pnpx vercel build
87+
if [ "${{ inputs.production-staged }}" = "true" ]; then
88+
unset PUBLIC_COLLAB_RELAY_URL
89+
pnpx vercel build --prod --token "${{ inputs.vercel-token }}"
90+
else
91+
export PUBLIC_COLLAB_RELAY_URL=${{ inputs.PUBLIC_COLLAB_RELAY_URL }}
92+
pnpx vercel build --token "${{ inputs.vercel-token }}"
93+
fi
8594
shell: bash
8695

8796
- name: Patch
@@ -108,9 +117,17 @@ runs:
108117
- name: Deploy
109118
id: deploy
110119
run: |
120+
deploy_args=(
121+
--prebuilt
122+
--token "${{ inputs.vercel-token }}"
123+
)
124+
125+
if [ "${{ inputs.production-staged }}" = "true" ]; then
126+
deploy_args+=(--prod --skip-domain)
127+
fi
128+
111129
pnpx vercel deploy \
112-
--prebuilt \
113-
--token ${{ inputs.vercel-token }} \
130+
"${deploy_args[@]}" \
114131
2> >(tee info.txt >&2) | tee domain.txt
115132
116133
echo "domain=$(cat ./domain.txt)" >> $GITHUB_OUTPUT

.github/workflows/vercel-deploy-staging.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ jobs:
8686
ref-name: ${{ github.event_name == 'pull_request_target' && format('pr-{0}', github.event.pull_request.number) || github.ref_name }}
8787
sha: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.sha || github.sha }}
8888
environment: ${{ matrix.environment }}
89+
production-staged: ${{ github.event_name == 'push' && matrix.environment == 'staging' && startsWith(github.ref_name, 'release-') && endsWith(github.ref_name, '.staging') }}
8990
PUBLIC_COLLAB_RELAY_URL: ${{ vars.PUBLIC_COLLAB_RELAY_URL }}
9091

9192
- name: Debug Vercel Outputs

apps/builder/app/builder/builder.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ import type { TokenPermissions } from "@webstudio-is/authorization-token";
5858
import { useToastErrors } from "~/shared/error/toast-error";
5959
import { initBuilderApi } from "~/shared/builder-api";
6060
import { updateWebstudioData } from "~/shared/instance-utils";
61-
import { migrateWebstudioDataMutable } from "@webstudio-is/sdk/migrations/webstudio-data";
61+
import { migrateWebstudioDataMutable } from "@webstudio-is/project-migrations";
6262
import { Loading, LoadingBackground } from "./shared/loading";
6363
import { mergeRefs } from "@react-aria/utils";
6464
import { CommandPanel } from "./features/command-panel";

apps/builder/app/builder/features/marketplace/utils.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import {
22
getStyleDeclKey,
3-
migratePages,
43
type Asset,
5-
type SerializedPages,
64
type WebstudioData,
75
} from "@webstudio-is/sdk";
6+
import {
7+
migratePages,
8+
type SerializedPages,
9+
} from "@webstudio-is/project-migrations/pages";
810
import type { CompactBuild } from "@webstudio-is/project-build";
911

1012
const getPair = <Item extends { id: string }>(item: Item) =>

apps/builder/app/routes/rest.$.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import type { LoaderFunctionArgs } from "@remix-run/server-runtime";
2+
import {
3+
ApiCompatibilityTarget,
4+
apiClientHeader,
5+
createApiCompatibilityPayload,
6+
} from "@webstudio-is/trpc-interface/api-compatibility";
7+
8+
const getTarget = (request: Request) => {
9+
const client = ApiCompatibilityTarget.safeParse(
10+
request.headers.get(apiClientHeader)
11+
);
12+
if (client.success) {
13+
return client.data;
14+
}
15+
16+
return "browser";
17+
};
18+
19+
const createResponse = (request: Request) => {
20+
const payload = createApiCompatibilityPayload({
21+
reason: "apiRouteNotFound",
22+
target: getTarget(request),
23+
});
24+
25+
return new Response(JSON.stringify({ success: false, error: payload }), {
26+
status: 426,
27+
headers: {
28+
"Content-Type": "application/json; charset=utf-8",
29+
"Cache-Control": "no-store",
30+
},
31+
});
32+
};
33+
34+
export const loader = ({ request }: LoaderFunctionArgs) => {
35+
return createResponse(request);
36+
};
37+
38+
export const action = loader;

apps/builder/app/routes/rest.data.$projectId.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { LoaderFunctionArgs } from "@remix-run/server-runtime";
22
import * as projectApi from "@webstudio-is/project/index.server";
33
import { loadDevBuildByProjectId } from "@webstudio-is/project-build/index.server";
4-
import { serializePages } from "@webstudio-is/sdk";
4+
import { serializePages } from "@webstudio-is/project-migrations/pages";
55
import { loadAssetsByProject } from "@webstudio-is/asset-uploader/index.server";
66
import { createContext } from "~/shared/context.server";
77
import { preventCrossOriginCookie } from "~/services/no-cross-origin-cookie";

apps/builder/app/services/auth-strategy/ws.server.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ const asyncLocalStorage = new AsyncLocalStorage<
1818
>();
1919

2020
// remix-auth-oauth2 logs OAuth state, PKCE verifier, and full callback URLs.
21-
createDebugRaw.enable(`${createDebugRaw.disable()},-OAuth2Strategy`);
21+
// Match both the exact namespace and any prefixed namespace enabled by DEBUG=*.
22+
createDebugRaw.enable(
23+
`${createDebugRaw.disable()},-OAuth2Strategy,-*OAuth2Strategy*`
24+
);
2225

2326
/**
2427
* The main issue with OAuth2Strategy is that it forces us to define authorizationEndpoint, tokenEndpoint, and redirectURI

apps/builder/app/services/trpc.server.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export const trpcSharedClient = createTrpcProxyServiceClient(
1212
url: TRPC_SERVER_URL,
1313
token: TRPC_SERVER_API_TOKEN,
1414
branchName: GITHUB_REF_NAME,
15+
clientVersion: staticEnv.GITHUB_SHA ?? "local",
1516
}
1617
: undefined
1718
);

apps/builder/app/shared/builder-data.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
import {
2-
getStyleDeclKey,
3-
migratePages,
4-
type WebstudioData,
5-
} from "@webstudio-is/sdk";
1+
import { getStyleDeclKey, type WebstudioData } from "@webstudio-is/sdk";
2+
import { migratePages } from "@webstudio-is/project-migrations/pages";
63
import type { MarketplaceProduct } from "@webstudio-is/project-build";
74
import type { Project } from "@webstudio-is/project";
85
import type { loader } from "~/routes/rest.data.$projectId";

apps/builder/app/shared/context.server.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ import { readLoginSessionBloomFilter } from "~/services/session.server";
1616
import type { BloomFilter } from "~/services/bloom-filter.server";
1717
import { isBuilder, isCanvas } from "./router-utils";
1818
import { parseBuilderUrl } from "@webstudio-is/http-client";
19+
import {
20+
ApiClient,
21+
apiClientHeader,
22+
apiClientVersionHeader,
23+
} from "@webstudio-is/trpc-interface/api-compatibility";
1924

2025
export const extractAuthFromRequest = async (request: Request) => {
2126
if (isCanvas(request)) {
@@ -180,6 +185,21 @@ const createTrpcCache = () => {
180185
};
181186
};
182187

188+
const createApiClientContext = (request: Request): AppContext["apiClient"] => {
189+
const client = ApiClient.safeParse(request.headers.get(apiClientHeader));
190+
if (client.success === false) {
191+
return {
192+
type: "unknown",
193+
version: undefined,
194+
};
195+
}
196+
197+
return {
198+
type: client.data,
199+
version: request.headers.get(apiClientVersionHeader) ?? undefined,
200+
};
201+
};
202+
183203
export const createPostgrestContext = () => {
184204
return { client: createClient(env.POSTGREST_URL, env.POSTGREST_API_KEY) };
185205
};
@@ -212,6 +232,7 @@ export const createContext = async (request: Request): Promise<AppContext> => {
212232
const entri = createEntriContext();
213233
const { planFeatures, purchases } = await resolvePlanInfo(authorization);
214234
const trpcCache = createTrpcCache();
235+
const apiClient = createApiClientContext(request);
215236

216237
const getOwnerPlanFeatures = async (userId: string) => {
217238
const results = await getPlanInfo([userId], { postgrest });
@@ -233,6 +254,7 @@ export const createContext = async (request: Request): Promise<AppContext> => {
233254
entri,
234255
planFeatures,
235256
purchases,
257+
apiClient,
236258
trpcCache,
237259
postgrest,
238260
createTokenContext,
@@ -247,6 +269,7 @@ export const createContext = async (request: Request): Promise<AppContext> => {
247269
entri,
248270
planFeatures,
249271
purchases,
272+
apiClient,
250273
trpcCache,
251274
postgrest,
252275
createTokenContext,

0 commit comments

Comments
 (0)