프론트엔드 netlify + Git action을 활용한 배포 구현 #45
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: FRONTEND-CD | |
| on: | |
| pull_request: | |
| types: [opened, synchronize, reopened] | |
| branches: | |
| - dev | |
| - main | |
| paths: | |
| - 'src/frontend/**' | |
| - '../workflows/fe-ci.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: Install dependencies | |
| run: | | |
| cd src/frontend | |
| pnpm install --strict-peer-dependencies=false --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: Prepare for Netlify | |
| run: | | |
| cd src/frontend/apps/web | |
| # standalone 디렉토리의 내용을 .next로 복사 | |
| cp -r .next/standalone/* .next/ | |
| # static 파일들도 복사 | |
| cp -r .next/static .next/standalone/apps/web/.next/ | |
| # public 디렉토리가 있다면 복사 | |
| [ -d "public" ] && cp -r public .next/standalone/apps/web/ || true | |
| - name: Deploy to Netlify | |
| uses: nwtgck/[email protected] | |
| with: | |
| publish-dir: 'src/frontend/apps/web/.next' # standalone이 아닌 전체 .next 디렉토리를 배포 | |
| 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 |