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
83 changes: 83 additions & 0 deletions .github/workflows/web-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Web UI deploy
on:
push:
branches:
- main
paths:
- '.github/workflows/web-*.yml'
- 'moon/**'

env:
TIPTAP_PRIVATE_REGISTRY_KEY: ${{ secrets.TIPTAP_PRIVATE_REGISTRY_KEY }}

jobs:
web-ui-deploy:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.base.ref }}

- uses: actions/setup-node@v4
with:
node-version: '20'

- name: Setup pnpm
uses: pnpm/action-setup@v4.0.0
with:
version: 9

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV

- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-

- run: pnpm config set "@tiptap-pro:registry" https://registry.tiptap.dev/
- run: pnpm config set "//registry.tiptap.dev/:_authToken" ${{ secrets.TIPTAP_PRIVATE_REGISTRY_KEY }}

- name: Install dependencies
working-directory: ./moon
run: pnpm i --frozen-lockfile

- name: Run ESLint
working-directory: ./moon
run: pnpm run lint

- name: Build Next.js application
working-directory: ./moon
run: pnpm run build

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1

- name: Login to Amazon ECR Public
id: login-ecr-public
uses: aws-actions/amazon-ecr-login@v2
with:
registry-type: public

- name: Build, tag, and push docker image to Amazon ECR Public
working-directory: moon
env:
REGISTRY: ${{ steps.login-ecr-public.outputs.registry }}
REGISTRY_ALIAS: m8q5m4u3
REPOSITORY: mega-ui
IMAGE_TAG: mega-ui-0.1.0-pre-release
run: |
docker build \
-t $REGISTRY/$REGISTRY_ALIAS/$REPOSITORY:$IMAGE_TAG .
docker push $REGISTRY/$REGISTRY_ALIAS/$REPOSITORY:$IMAGE_TAG
7 changes: 2 additions & 5 deletions .github/workflows/web-test.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: Test Web UI
on:
pull_request:
Comment thread
liuyangjuncong20202570 marked this conversation as resolved.
push:
branches:
- main
paths:
Expand All @@ -17,12 +16,11 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:

- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
# ref: ${{ github.event.pull_request.base.ref }}
ref: ${{ github.event.pull_request.base.ref }}

- uses: actions/setup-node@v4
with:
Expand All @@ -48,11 +46,10 @@ jobs:

- run: pnpm config set "@tiptap-pro:registry" https://registry.tiptap.dev/
- run: pnpm config set "//registry.tiptap.dev/:_authToken" ${{ env.TIPTAP_PRIVATE_REGISTRY_KEY }}
- run: pnpm -v

- name: Install dependencies
working-directory: ./moon
run: pnpm i --no-frozen-lockfile
run: pnpm i --frozen-lockfile

- name: Run ESLint
working-directory: ./moon
Expand Down
16 changes: 16 additions & 0 deletions moon/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM node:20-alpine AS runner

WORKDIR /app

ENV PORT=3000

# 安装 pnpm(保持一致版本)
RUN corepack enable && corepack prepare pnpm@9.7.1 --activate

# 拷贝构建产物和依赖
COPY . .

# 启动 SSR 服务
WORKDIR /app/apps/web
CMD ["pnpm", "start"]

3 changes: 2 additions & 1 deletion moon/apps/web/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const cspResourcesByDirective = {
'blob:',
'https://*.gitmono.com',
'wss://*.gitmono.com',
'http://*.gitmega.com',
Comment thread
benjamin-747 marked this conversation as resolved.
process.env.NODE_ENV !== 'production' && 'http://api.gitmega.com',
process.env.NODE_ENV !== 'production' && 'http://git.gitmega.com',
process.env.NODE_ENV !== 'production' && 'ws://localhost:9000',
Expand Down Expand Up @@ -72,7 +73,7 @@ const cspResourcesByDirective = {
process.env.NODE_ENV !== 'production' && 'https://campsite-dev.imgix.net',
process.env.NODE_ENV !== 'production' && 'https://campsite-dev.imgix.video',
process.env.NODE_ENV !== 'production' && 'https://campsite-api-dev.imgix.net',
process.env.NODE_ENV !== 'production' && 'http://api.gitmega.com',
'http://*.gitmega.com',
'https://media.tenor.com' // used for Tenor gifs,
],
'manifest-src': ["'self'"],
Expand Down
2 changes: 1 addition & 1 deletion moon/apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"dev": "next dev -p 80",
"lint": "next lint",
"playwright": "playwright test",
"start": "next start",
"start": "next start -p 3000 -H 0.0.0.0",
Comment thread
liuyangjuncong20202570 marked this conversation as resolved.
"storybook": "storybook dev -p 6006",
"test": "vitest"
},
Expand Down
5 changes: 5 additions & 0 deletions moon/apps/web/pages/api/health.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import type { NextApiRequest, NextApiResponse } from 'next'

export default function handler(_req: NextApiRequest, res: NextApiResponse) {
res.status(200).json({ status: 'ok' })
}
15 changes: 12 additions & 3 deletions moon/apps/web/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@
"strictNullChecks": true
},
"extends": "@gitmono/tsconfig/nextjs.json",
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "vitest.config.mts", "**/*.config.js", ".next/types/**/*.ts"],
"exclude": ["node_modules"]
}
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
"vitest.config.mts",
"**/*.config.js",
".next/types/**/*.ts"
],
"exclude": [
"node_modules"
]
}
5 changes: 2 additions & 3 deletions moon/apps/web/utils/queryClient.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { InfiniteData, QueryClient, QueryKey } from '@tanstack/react-query'

import { RAILS_API_URL, RAILS_AUTH_URL, LEGACY_API_URL } from '@gitmono/config'
import { LEGACY_API_URL, RAILS_API_URL, RAILS_AUTH_URL } from '@gitmono/config'
import { Api, ApiError, DataTag } from '@gitmono/types'
import { InfiniteData, QueryClient, QueryKey } from '@tanstack/react-query'

import { ApiErrorResponse } from './types'

Expand Down
2 changes: 1 addition & 1 deletion moon/packages/config/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const SITE_URL_DEV = 'http://gitmono.test:3003'
const SYNC_URL_PROD = 'wss://sync.gitmono.com'
const SYNC_URL_DEV = 'ws://localhost:9000'

export const IS_PRODUCTION = process.env.NODE_ENV === 'production'
export const IS_PRODUCTION = process.env.APP_ENV === 'production'
export const SCOPE_COOKIE_NAME = 'scope'
export const POLL_OPTION_DESCRIPTION_LENGTH = 32

Expand Down