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
37 changes: 22 additions & 15 deletions .github/workflows/web-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@ concurrency:
cancel-in-progress: true

jobs:
web-ui-deploy:
build:
runs-on: ubuntu-latest
strategy:
matrix:
env_name: [staging, staging-nju]
timeout-minutes: 10
steps:
- name: Checkout repository
Expand All @@ -44,26 +47,30 @@ jobs:
with:
registry-type: public

- name: Build, tag, and push docker image to Amazon ECR Public
- name: Build, tag, and push docker image (${{ matrix.env_name }}) 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
REPOSITORY: mega
IMAGE_TAG: mega-ui-${{ matrix.env_name }}-0.1.0-pre-release
run: |
docker build \
--build-arg APP_ENV=${{ matrix.env_name }} \
-f apps/web/Dockerfile \
-t $REGISTRY/$REGISTRY_ALIAS/$REPOSITORY:$IMAGE_TAG .
docker push $REGISTRY/$REGISTRY_ALIAS/$REPOSITORY:$IMAGE_TAG

- name: Force ECS redeploy
run: |
aws ecs update-service \
--cluster ${{ secrets.AWS_ECS_CLUSTER_NAME }} \
--service ${{ secrets.AWS_ECS_WEB_SERVICE_NAME }} \
--force-new-deployment
env:
AWS_REGION: ap-southeast-2
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
deploy:
needs: build
runs-on: ubuntu-latest
steps:
- name: Force ECS redeploy

Copilot AI Jul 31, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ECS redeploy step in the deploy job will fail because it references variables (REGISTRY, REGISTRY_ALIAS, REPOSITORY, IMAGE_TAG) that are only defined in the build job's matrix strategy. These variables need to be passed to the deploy job or redefined in the deploy job context.

Copilot uses AI. Check for mistakes.
run: |
aws ecs update-service \
--cluster ${{ secrets.AWS_ECS_CLUSTER_NAME }} \
--service ${{ secrets.AWS_ECS_WEB_SERVICE_NAME }} \
--force-new-deployment
env:
AWS_REGION: ap-southeast-2
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
5 changes: 5 additions & 0 deletions moon/apps/web/.env.staging
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
NEXT_PUBLIC_API_URL=https://api.gitmega.com
NEXT_PUBLIC_MONO_API_URL=https://git.gitmega.com
NEXT_PUBLIC_WEB_URL=https://app.gitmega.com
NEXT_PUBLIC_SYNC_URL=wss://sync.gitmega.com
NEXT_PUBLIC_AUTH_URL=https://auth.gitmega.com
5 changes: 5 additions & 0 deletions moon/apps/web/.env.staging-nju
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
NEXT_PUBLIC_API_URL=http://api.gitmega.nju:8080
NEXT_PUBLIC_MONO_API_URL=http://git.gitmega.nju:8080
NEXT_PUBLIC_WEB_URL=http://app.gitmega.nju:8080
NEXT_PUBLIC_SYNC_URL=ws://sync.gitmega.nju:8080
NEXT_PUBLIC_AUTH_URL=http://auth.gitmega.nju:8080
5 changes: 5 additions & 0 deletions moon/apps/web/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

FROM node:20-slim AS base

ARG APP_ENV=staging
ENV APP_ENV=${APP_ENV}

# configure pnpm
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
Expand Down Expand Up @@ -41,6 +44,8 @@ RUN npx patch-package

COPY --from=builder /app/out/full/ .

RUN cp /app/apps/web/.env.${APP_ENV} /app/apps/web/.env.production

Copilot AI Jul 31, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The copy command will fail if the source file doesn't exist. For example, if APP_ENV is set to a value that doesn't have a corresponding .env file, the build will fail. Consider adding a check to ensure the source file exists before copying, or provide a fallback mechanism.

Suggested change
RUN cp /app/apps/web/.env.${APP_ENV} /app/apps/web/.env.production
RUN if [ -f /app/apps/web/.env.${APP_ENV} ]; then \
cp /app/apps/web/.env.${APP_ENV} /app/apps/web/.env.production; \
else \
cp /app/apps/web/.env.default /app/apps/web/.env.production; \
fi

Copilot uses AI. Check for mistakes.

RUN npx turbo run build --filter=@gitmono/web


Expand Down
8 changes: 4 additions & 4 deletions moon/apps/web/components/CodeView/TreeView/CloneTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Box, Flex, Tabs } from '@radix-ui/themes'
import copy from 'copy-to-clipboard'
import { usePathname } from 'next/navigation'

import { LEGACY_API_URL } from '@gitmono/config'
import { MONO_API_URL } from '@gitmono/config'
import { Button, cn, Popover, PopoverContent, PopoverPortal, PopoverTrigger } from '@gitmono/ui'
import { CheckIcon, CopyIcon, DownloadIcon } from '@gitmono/ui/Icons'

Expand All @@ -13,11 +13,11 @@ const CloneTabs = ({ endpoint }: any) => {
const [copied, setCopied] = useState<boolean>(false)
const [active_tab, setActiveTab] = useState<string>('HTTP')
const [open, setOpen] = useState(false)
const url = new URL(LEGACY_API_URL)
const url = new URL(MONO_API_URL)

useEffect(() => {
if (LEGACY_API_URL) {
const url = new URL(LEGACY_API_URL)
if (MONO_API_URL) {
const url = new URL(MONO_API_URL)

if (active_tab === '1') {
setText(`${url.href}${pathname?.replace('/myorganization/code/tree/', '')}.git`)
Expand Down
4 changes: 2 additions & 2 deletions moon/apps/web/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ const cspResourcesByDirective = {
'http://*.gitmega.com',
'http://*.gitmono.test:3001',
'http://*.gitmono.test:8000',
process.env.NODE_ENV !== 'production' && 'https://api.gitmega.com',
process.env.NODE_ENV !== 'production' && 'https://git.gitmega.com',
'http://*.gitmega.nju:8080',
'http://*.gitmega.nju',
process.env.NODE_ENV !== 'production' && 'localhost:8000',
process.env.NODE_ENV !== 'production' && 'ws://localhost:9000',
'https://gitmono.s3.ap-southeast-2.amazonaws.com',
Expand Down
4 changes: 2 additions & 2 deletions moon/apps/web/utils/queryClient.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LEGACY_API_URL, RAILS_API_URL, RAILS_AUTH_URL } from '@gitmono/config'
import { MONO_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'

Expand Down Expand Up @@ -146,7 +146,7 @@ export const apiClient = new Api({
})

export const legacyApiClient = new Api({
baseUrl: LEGACY_API_URL,
baseUrl: MONO_API_URL,
baseApiParams: {
credentials: 'include',
headers: { 'Content-Type': 'application/json' },
Expand Down
24 changes: 5 additions & 19 deletions moon/packages/config/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,38 +1,24 @@
const WEB_URL_PROD = 'https://app.gitmono.com'
const WEB_URL_DEV = 'http://app.gitmono.test'

const SITE_URL_PROD = 'https://www.gitmono.com'
const SITE_URL_DEV = 'http://gitmono.test:3003'

const SYNC_URL_PROD = 'wss://sync.gitmono.com'
const SYNC_URL_DEV = 'wss://sync.gitmega.com'

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

export const IS_NGROK = !!process.env.NEXT_PUBLIC_IS_NGROK

export const WEB_URL = IS_PRODUCTION ? WEB_URL_PROD : process.env.NEXT_PUBLIC_WEB_URL || WEB_URL_DEV
export const WEB_URL = process.env.NEXT_PUBLIC_WEB_URL || 'https://app.gitmega.com'
export const SITE_URL = IS_PRODUCTION ? SITE_URL_PROD : SITE_URL_DEV
export const SYNC_URL = IS_PRODUCTION ? SYNC_URL_PROD : process.env.NEXT_PUBLIC_SYNC_URL || SYNC_URL_DEV
export const SYNC_URL = process.env.NEXT_PUBLIC_SYNC_URL || 'wss://sync.gitmega.com'

export const DESKTOP_APP_PROTOCOL = IS_PRODUCTION ? 'campsite://' : 'campsite-dev://'
export const LAST_CLIENT_JS_BUILD_ID_LS_KEY = 'latest-js-time'

export const RAILS_API_URL = IS_PRODUCTION
? 'https://api.gitmono.com'
: process.env.NEXT_PUBLIC_API_URL || 'https://api.gitmega.com'

export const LEGACY_API_URL = IS_PRODUCTION
? 'https://git.gitmono.com'
: process.env.NEXT_PUBLIC_LEGACY_API_URL || 'https://git.gitmega.com'
export const RAILS_API_URL = process.env.NEXT_PUBLIC_API_URL || 'https://api.gitmega.com'

const RAILS_AUTH_URL_PROD_COM = 'https://auth.gitmono.com'
export const MONO_API_URL = process.env.NEXT_PUBLIC_MONO_API_URL || 'https://git.gitmega.com'

export const RAILS_AUTH_URL = IS_PRODUCTION
? RAILS_AUTH_URL_PROD_COM
: process.env.NEXT_PUBLIC_AUTH_URL || 'https://auth.gitmega.com'
export const RAILS_AUTH_URL = process.env.NEXT_PUBLIC_AUTH_URL || 'https://auth.gitmega.com'

/*
Not using an env variable because we use this variable in the browser, which
Expand Down
Loading