hosted: upload sitemaps to posthog in ci (#130)

This commit is contained in:
Ben Senescu 2026-04-22 17:29:37 -04:00 committed by GitHub
parent c779d83cda
commit d23cad7abf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 49 additions and 0 deletions

42
.github/workflows/sourcemaps.yml vendored Normal file
View File

@ -0,0 +1,42 @@
name: Upload sourcemaps
on:
push:
branches:
- main
concurrency:
group: sourcemaps-${{ github.ref }}
cancel-in-progress: true
jobs:
upload:
if: github.repository != 'every-app/open-seo'
runs-on: ubuntu-latest
env:
POSTHOG_SOURCEMAPS: "true"
POSTHOG_CLI_HOST: ${{ secrets.POSTHOG_CLI_HOST }}
POSTHOG_CLI_PROJECT_ID: ${{ secrets.POSTHOG_CLI_PROJECT_ID }}
POSTHOG_CLI_API_KEY: ${{ secrets.POSTHOG_CLI_API_KEY }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 9
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build and upload sourcemaps
run: pnpm run sourcemaps:upload

1
.gitignore vendored
View File

@ -4,6 +4,7 @@ package-lock.json
yarn.lock
.dev.vars
dist/
dist-sourcemaps/
.wrangler
/tmp

View File

@ -13,6 +13,7 @@
"lint:fix": "oxlint . --type-aware --fix",
"preview": "npm run build && vite preview --port 3001",
"deploy": "npm run db:migrate:prod && npm run build && wrangler deploy",
"sourcemaps:upload": "POSTHOG_SOURCEMAPS=true npm run build && pnpm dlx @posthog/cli sourcemap inject --directory ./dist-sourcemaps && pnpm dlx @posthog/cli sourcemap upload --directory ./dist-sourcemaps",
"cf-typegen": "wrangler types",
"types:check": "tsc --noEmit",
"format:check": "prettier --check .",

View File

@ -11,6 +11,7 @@ export default defineConfig(({ mode }) => {
const port = env.PORT ? Number(env.PORT) : 3001;
const showDevtools = env.VITE_SHOW_DEVTOOLS !== "false";
const allowedHosts = env.ALLOWED_HOST ? [env.ALLOWED_HOST] : undefined;
const emitSourcemaps = env.POSTHOG_SOURCEMAPS === "true";
return {
envPrefix: ["VITE_", "AUTH_MODE", "POSTHOG_PUBLIC_KEY", "POSTHOG_HOST"],
@ -21,6 +22,10 @@ export default defineConfig(({ mode }) => {
allowedHosts,
port,
},
build: {
sourcemap: emitSourcemaps,
outDir: emitSourcemaps ? "dist-sourcemaps" : "dist",
},
plugins: [
showDevtools
? devtools({