diff --git a/.github/workflows/deploy-cloudflare-pages.yml b/.github/workflows/deploy-cloudflare-pages.yml new file mode 100644 index 000000000..0db4fa654 --- /dev/null +++ b/.github/workflows/deploy-cloudflare-pages.yml @@ -0,0 +1,52 @@ +name: Cloudflare Pages + +on: + push: + branches: + - 'main' + +jobs: + deploy: + name: Deploy - ${{ matrix.app }} + runs-on: ubuntu-latest + permissions: + contents: read + deployments: write + + strategy: + matrix: + include: + - app: stage-web + environment_name: Production + environment_url: https://airi.moeru.ai/docs/ + cloudflare_pages_id: proj-airi + dist_directory: ./apps/stage-web/dist + command: | + pnpm -F @proj-airi/stage-web run build + + pnpm -F @proj-airi/docs run build:base + mv ./docs/.vitepress/dist ./apps/stage-web/dist/docs + cp ./apps/stage-web/dist/docs/sitemap.xml ./apps/stage-web/dist/sitemap.xml + + pnpm -F @proj-airi/stage-ui run story:build + mv ./packages/stage-ui/.histoire/dist ./apps/stage-web/dist/ui + + environment: + name: ${{ matrix.environment_name }} + url: ${{ matrix.environment_url }} + + steps: + - uses: actions/checkout@v6 + - uses: pnpm/action-setup@v4 + - uses: actions/setup-node@v6 + with: + cache: pnpm + node-version: latest + registry-url: https://registry.npmjs.org + - run: ${{ matrix.command }} + - uses: cloudflare/wrangler-action@v3 + with: + apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} + accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + command: pages deploy ${{ matrix.dist_directory }} --project-name=${{ matrix.cloudflare_pages_id }} + gitHubToken: ${{ secrets.GITHUB_TOKEN }} diff --git a/apps/stage-web/public/.assetsignore b/apps/stage-web/public/.assetsignore new file mode 100644 index 000000000..421c66e16 --- /dev/null +++ b/apps/stage-web/public/.assetsignore @@ -0,0 +1,3 @@ +**/node_modules +**/.DS_Store +**/.git diff --git a/apps/stage-web/public/_redirects b/apps/stage-web/public/_redirects index 9a3df2815..02c2d02a8 100644 --- a/apps/stage-web/public/_redirects +++ b/apps/stage-web/public/_redirects @@ -1,4 +1,16 @@ +# Plausible.io analytics +# +# Originally proxying Plausible through Netlify | Plausible docs +# https://plausible.io/docs/proxy/guides/netlify + +/remote-assets/page-external-data/js/script.js https://plausible.io/js/script.js 200 +/api/v1/page-external-data/submit https://plausible.io/api/event 200 + # i18n -/docs/* /docs/zh-Hans/:splat 301 Language=zh-Hans -/docs/* /docs/zh-Hans/:splat 301 Language=zh-CN -/docs/* /docs/en/:splat 301 +/docs/* /docs/zh-Hans/:splat 301 Language=zh-Hans +/docs/* /docs/zh-Hans/:splat 301 Language=zh-CN +/docs/* /docs/en/:splat 301 + +# Static assets +/assets/* /assets/:splat 200 +/* /index.html 200 diff --git a/apps/stage-web/wrangler.toml b/apps/stage-web/wrangler.toml new file mode 100644 index 000000000..7ae497f26 --- /dev/null +++ b/apps/stage-web/wrangler.toml @@ -0,0 +1,10 @@ +name = "airi" +compatibility_date = "2025-04-01" +preview_urls = true + +[build] +command = "pnpm -F @proj-airi/stage-web run build && pnpm -F @proj-airi/docs run build:base && mv ./docs/.vitepress/dist ./apps/stage-web/dist/docs && cp ./apps/stage-web/dist/docs/sitemap.xml ./apps/stage-web/dist/sitemap.xml && pnpm -F @proj-airi/stage-ui run story:build && mv ./packages/stage-ui/.histoire/dist ./apps/stage-web/dist/ui" + +[assets] +directory = "./dist" +not_found_handling = "single-page-application"