mirror of
https://github.com/moeru-ai/airi.git
synced 2026-05-17 04:20:26 +00:00
--------- Signed-off-by: Salman Muin Kayser Chishti <13schishti@gmail.com> Co-authored-by: Neko <neko@ayaka.moe>
97 lines
3.5 KiB
YAML
97 lines
3.5 KiB
YAML
name: Cloudflare Workers
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- 'main'
|
|
|
|
workflow_dispatch:
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
deploy:
|
|
name: Deploy - ${{ matrix.app_name }}
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
deployments: write
|
|
|
|
strategy:
|
|
matrix:
|
|
include:
|
|
- app_name: stage-web
|
|
environment_name: Production
|
|
environment_url: https://airi.moeru.ai/docs/
|
|
cloudflare_pages_id: moeru-ai-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
|
|
# Turborepo
|
|
- name: Cache turbo build setup
|
|
uses: actions/cache@v5
|
|
with:
|
|
path: .turbo
|
|
key: ${{ runner.os }}-turbo-${{ github.sha }}
|
|
restore-keys: |
|
|
${{ runner.os }}-turbo-
|
|
- uses: pnpm/action-setup@v4
|
|
- uses: actions/setup-node@v6
|
|
with:
|
|
node-version: lts/*
|
|
cache: pnpm
|
|
# NOTICE:
|
|
#
|
|
# Here installing wrangler to global is required, or otherwise:
|
|
# ERR_PNPM_ADDING_TO_ROOT Running this command will add the dependency to the workspace root...
|
|
# error occurs.
|
|
#
|
|
# Since https://github.com/cloudflare/wrangler-action/pull/339#issuecomment-2667622947 rejected the -g support
|
|
# by saying un-reasonable 'I'm not sure if it's common ... to install packages to the global scope, ... might be introducing some unintended side effects.'
|
|
#
|
|
# Clearly I think installing with `<packageManager> install` brings more unintended side effects...
|
|
#
|
|
# As suggested by https://github.com/cloudflare/wrangler-action/issues/181#issuecomment-2127990708, we should pre-install
|
|
# with our package manager and then use it in the action.
|
|
- run: pnpm i -g wrangler@4
|
|
- run: pnpm install --frozen-lockfile
|
|
- run: pnpm run build:packages
|
|
- run: ${{ matrix.command }}
|
|
env:
|
|
S3_ACCESS_KEY_ID: ${{ secrets.S3_ACCESS_KEY_ID }}
|
|
S3_SECRET_ACCESS_KEY: ${{ secrets.S3_SECRET_ACCESS_KEY }}
|
|
S3_ENDPOINT: ${{ secrets.S3_ENDPOINT }}
|
|
S3_REGION: ${{ secrets.S3_REGION }}
|
|
VITE_ENABLE_POSTHOG: 'true'
|
|
WARP_DRIVE_PUBLIC_BASE: ${{ secrets.WARP_DRIVE_PUBLIC_BASE }}
|
|
- run: |
|
|
CI=true pnpm install -g @posthog/cli
|
|
pnpm exec posthog-cli sourcemap inject --directory ${{ matrix.dist_directory }}
|
|
pnpm exec posthog-cli sourcemap upload --directory ${{ matrix.dist_directory }}
|
|
env:
|
|
POSTHOG_CLI_ENV_ID: ${{ secrets.POSTHOG_ENV_ID }}
|
|
POSTHOG_CLI_TOKEN: ${{ secrets.POSTHOG_TOKEN }}
|
|
continue-on-error: true
|
|
|
|
- uses: cloudflare/wrangler-action@v3.14.1
|
|
with:
|
|
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
|
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
|
command: deploy -c ./apps/stage-web/wrangler.toml
|
|
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
|