프론트엔드 netlify + Git action을 활용한 배포 구현 #50
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/**' | |
| - '.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: 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/[email protected] | |
| with: | |
| publish-dir: 'src/frontend/apps/web/.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 |