[FEATURE] 초기 세팅 진행 #2
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: Preview | |
| on: | |
| pull_request: | |
| branches: ['develop'] | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| concurrency: | |
| group: preview-${{ github.event.pull_request.number }} | |
| cancel-in-progress: true | |
| jobs: | |
| checks: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| # Setup Node with npm cache (package-lock.json) | |
| - name: Setup Node (npm cache) | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: 'npm' | |
| cache-dependency-path: 'package-lock.json' | |
| - name: Show versions | |
| run: | | |
| node -v | |
| npm -v | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Lint (if present) | |
| run: npm run --if-present lint | |
| - name: Typecheck (if present) | |
| run: npm run --if-present typecheck | |
| - name: Test (if present) | |
| run: npm run --if-present test -- --passWithNoTests | |
| - name: Build | |
| run: npm run build | |
| vercel-preview: | |
| if: ${{ github.event.pull_request.head.repo.full_name == github.repository && !github.event.pull_request.draft }} | |
| needs: checks | |
| runs-on: ubuntu-latest | |
| env: | |
| VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} | |
| VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Node (npm cache) | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: 'npm' | |
| cache-dependency-path: 'package-lock.json' | |
| - name: Show versions | |
| run: | | |
| node -v | |
| npm -v | |
| - name: Install Vercel CLI | |
| run: npm install --global vercel@latest | |
| - name: Pull Vercel Env (preview) | |
| env: | |
| VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} | |
| run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }} | |
| - name: Build Project Artifacts (prebuilt) | |
| env: | |
| VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} | |
| run: vercel build --token=${{ secrets.VERCEL_TOKEN }} | |
| - name: Deploy Preview | |
| id: deploy | |
| env: | |
| VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} | |
| run: | | |
| url=$(vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }}) | |
| echo "preview_url=$url" >> $GITHUB_OUTPUT | |
| - name: Comment PR with Preview URL | |
| uses: thollander/actions-comment-pull-request@v2 | |
| with: | |
| message: | | |
| ✅ PREVIEW: ${{ steps.deploy.outputs.preview_url }} |