diff --git a/.github/workflows/fe-cd.yml b/.github/workflows/fe-cd.yml new file mode 100644 index 00000000..93e4aabd --- /dev/null +++ b/.github/workflows/fe-cd.yml @@ -0,0 +1,112 @@ +name: FRONTEND-CD + +on: + pull_request: + types: [opened, synchronize, reopened] + branches: + - dev + - main + paths: + - 'src/frontend/**' + - '.github/workflows/fe-cd.yml' + +permissions: + contents: read + deployments: write + pull-requests: write + statuses: write + checks: write + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + changes: + if: ${{ github.actor != 'l10nbot' }} + runs-on: ubuntu-latest + timeout-minutes: 15 + + steps: + - name: Check out code + uses: actions/checkout@v4 + with: + fetch-depth: 2 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + + - uses: pnpm/action-setup@v4 + with: + version: 8 + + - name: Cache dependencies + uses: actions/cache@v4 + with: + path: | + ~/.pnpm-store + **/node_modules + src/frontend/node_modules + key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm- + + - name: Cache turbo build + uses: actions/cache@v4 + with: + path: | + src/frontend/.turbo + src/frontend/apps/web/.next/cache + key: ${{ runner.os }}-turbo-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-turbo- + + - name: Prepare Netlify functions + run: | + cd src/frontend/apps/web + mkdir -p netlify/functions + + - name: Install dependencies + run: | + cd src/frontend + pnpm install --no-frozen-lockfile + pnpm add turbo --save-dev -w + + - name: Build + run: | + cd src/frontend + pnpm turbo build + echo "🔍 Checking build output..." + ls -la apps/web/.next + + - name: Deploy to Netlify + uses: nwtgck/actions-netlify@v2.0 + with: + publish-dir: 'src/frontend/apps/web/.next' + functions-dir: 'src/frontend/apps/web/netlify/functions' + production-branch: '["main", "dev"]' + github-token: ${{ secrets.PAT_GITHUB_TOKEN }} + deploy-message: 'Deploy from GitHub Actions' + enable-pull-request-comment: true + enable-commit-comment: true + enable-commit-status: true + overwrites-pull-request-comment: true + fails-without-credentials: true + netlify-config-path: 'src/frontend/netlify.toml' + alias: deploy-preview-${{ github.event.number }} + env: + PNPM_HOME: /home/runner/setup-pnpm/node_modules/.bin + NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} + NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} + timeout-minutes: 10 + + required: + needs: [changes] + if: always() + runs-on: ubuntu-latest + steps: + - name: fail if conditional jobs failed + if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'skipped') || contains(needs.*.result, 'cancelled') + run: exit 1 diff --git a/.github/workflows/fe-ci.yml b/.github/workflows/fe-ci.yml index d1fd41f4..20d548ee 100644 --- a/.github/workflows/fe-ci.yml +++ b/.github/workflows/fe-ci.yml @@ -35,7 +35,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: 22 + node-version: 20 - uses: pnpm/action-setup@v3 with: diff --git a/src/frontend/.gitignore b/src/frontend/.gitignore index cb4a7e05..43fd09ac 100644 --- a/src/frontend/.gitignore +++ b/src/frontend/.gitignore @@ -20,6 +20,9 @@ out/ build dist +# Next.js telemetry +.netlify + # Debug npm-debug.log* diff --git a/src/frontend/apps/web/next.config.mjs b/src/frontend/apps/web/next.config.mjs index 698b5d23..c1b72c1c 100644 --- a/src/frontend/apps/web/next.config.mjs +++ b/src/frontend/apps/web/next.config.mjs @@ -1,5 +1,6 @@ /** @type {import('next').NextConfig} */ const nextConfig = { + output: 'standalone', // standalone 출력 추가 transpilePackages: ['@workspace/ui'], }; diff --git a/src/frontend/netlify.toml b/src/frontend/netlify.toml new file mode 100644 index 00000000..0f0716cb --- /dev/null +++ b/src/frontend/netlify.toml @@ -0,0 +1,13 @@ +[build] + base = "src/frontend/apps/web" + command = "pnpm build" + publish = ".next" + ignore = "git diff --quiet $CACHED_COMMIT_REF $COMMIT_REF . ../../../" + +[build.environment] + NODE_VERSION = "20" + NEXT_TELEMETRY_DISABLED = "1" + +[[plugins]] + package = "@netlify/plugin-nextjs" + diff --git a/src/frontend/package.json b/src/frontend/package.json index 2003a99b..cfa33c52 100644 --- a/src/frontend/package.json +++ b/src/frontend/package.json @@ -4,6 +4,7 @@ "private": false, "scripts": { "build": "turbo build", + "build:web": "turbo run build --filter=web...", "dev": "turbo dev", "lint": "turbo lint", "format": "turbo run format", @@ -12,6 +13,7 @@ "typescript": "turbo run typescript" }, "devDependencies": { + "@netlify/plugin-nextjs": "^5.9.4", "@workspace/eslint-config": "workspace:*", "@workspace/typescript-config": "workspace:*", "danger": "^12.3.3", diff --git a/src/frontend/pnpm-lock.yaml b/src/frontend/pnpm-lock.yaml index 038f459d..c571320a 100644 --- a/src/frontend/pnpm-lock.yaml +++ b/src/frontend/pnpm-lock.yaml @@ -8,6 +8,9 @@ importers: .: devDependencies: + '@netlify/plugin-nextjs': + specifier: ^5.9.4 + version: 5.9.4 '@workspace/eslint-config': specifier: workspace:* version: link:packages/eslint-config @@ -617,6 +620,10 @@ packages: '@types/react': '>=16' react: '>=16' + '@netlify/plugin-nextjs@5.9.4': + resolution: {integrity: sha512-Q9qyhGUxFuM3kuWmoaj4yHPUfHhOsZmwdsQv4kIXkBWVu8FOe0RFHRP0A0EXciSVFGwq+XAo3H5jEtVSANAOWw==} + engines: {node: '>=18.0.0'} + '@next/env@14.2.23': resolution: {integrity: sha512-CysUC9IO+2Bh0omJ3qrb47S8DtsTKbFidGm6ow4gXIG6reZybqxbkH2nhdEm1tC8SmgzDdpq3BIML0PWsmyUYA==} @@ -2856,6 +2863,7 @@ packages: lodash.get@4.4.2: resolution: {integrity: sha512-z+Uw/vLuy6gQe8cfaFWD7p0wVv8fJl3mbzXh33RS+0oW2wvUqiRXiQ69gLWSLpgB5/6sU+r6BlQR0MBILadqTQ==} + deprecated: This package is deprecated. Use the optional chaining (?.) operator instead. lodash.includes@4.3.0: resolution: {integrity: sha512-W3Bx6mdkRTGtlJISOvVD/lbqjTlPPUDTMnlXZFnVwi9NKJ6tiAk6LVdlhZMm17VZisqhKcgzpO5Wz91PCt5b0w==} @@ -4538,6 +4546,8 @@ snapshots: '@types/react': 19.0.7 react: 18.3.1 + '@netlify/plugin-nextjs@5.9.4': {} + '@next/env@14.2.23': {} '@next/eslint-plugin-next@15.1.5': diff --git a/src/frontend/turbo.json b/src/frontend/turbo.json index 03609e11..9a4aac78 100644 --- a/src/frontend/turbo.json +++ b/src/frontend/turbo.json @@ -3,9 +3,8 @@ "ui": "tui", "tasks": { "build": { - "dependsOn": ["^build"], - "inputs": ["$TURBO_DEFAULT$", ".env*"], - "outputs": [".next/**"] + "outputs": [".next/**", "!.next/cache/**", "dist/**", "build/**"], + "dependsOn": ["^build"] }, "build-storybook": { "dependsOn": ["^build-storybook"], @@ -39,7 +38,11 @@ }, "typescript": { "dependsOn": ["^typescript"], - "inputs": ["$TURBO_DEFAULT$", "tsconfig.json", "packages/**/tsconfig.json"], + "inputs": [ + "$TURBO_DEFAULT$", + "tsconfig.json", + "packages/**/tsconfig.json" + ], "cache": true, "persistent": false }