|
| 1 | +name: Deploy to Vercel |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: ['master', 'vercel'] |
| 6 | + |
| 7 | +jobs: |
| 8 | + build-and-deploy: |
| 9 | + environment: vercel |
| 10 | + runs-on: ubuntu-latest |
| 11 | + |
| 12 | + steps: |
| 13 | + - name: Checkout code |
| 14 | + if: ${{ !contains(github.event.head_commit.message, '[skip deploy]') }} |
| 15 | + uses: actions/checkout@v4 |
| 16 | + |
| 17 | + - name: Set up Node.js |
| 18 | + if: ${{ !contains(github.event.head_commit.message, '[skip deploy]') }} |
| 19 | + uses: actions/setup-node@v4 |
| 20 | + with: |
| 21 | + node-version: '22.11.0' |
| 22 | + |
| 23 | + - name: Install dependencies |
| 24 | + if: ${{ !contains(github.event.head_commit.message, '[skip deploy]') }} |
| 25 | + uses: borales/actions-yarn@v4 |
| 26 | + with: |
| 27 | + cmd: install |
| 28 | + |
| 29 | + - name: Install Vercel CLI |
| 30 | + if: ${{ !contains(github.event.head_commit.message, '[skip deploy]') }} |
| 31 | + run: npm install --global vercel@latest |
| 32 | + |
| 33 | + - name: Pull Vercel Environment Information |
| 34 | + if: ${{ !contains(github.event.head_commit.message, '[skip deploy]') }} |
| 35 | + run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }} |
| 36 | + |
| 37 | + - name: Build project |
| 38 | + if: ${{ !contains(github.event.head_commit.message, '[skip deploy]') }} |
| 39 | + run: | |
| 40 | + cp -r .vercel/.env.production.local .env |
| 41 | + npx --yes tsx update-files-for-vercel.ts |
| 42 | + npm run manual-supabase-build |
| 43 | +
|
| 44 | + - name: Remove devDependencies |
| 45 | + if: ${{ !contains(github.event.head_commit.message, '[skip deploy]') }} |
| 46 | + run: echo $(cat package.json | jq 'del(.devDependencies)') > package.json |
| 47 | + |
| 48 | + - name: Remove yarn lock file |
| 49 | + if: ${{ !contains(github.event.head_commit.message, '[skip deploy]') }} |
| 50 | + run: rm -rf yarn.lock |
| 51 | + |
| 52 | + - name: Copy the settings |
| 53 | + if: ${{ !contains(github.event.head_commit.message, '[skip deploy]') }} |
| 54 | + run: cp -r .docker/nx.json nx.json |
| 55 | + |
| 56 | + - name: Install only prod dependencies |
| 57 | + if: ${{ !contains(github.event.head_commit.message, '[skip deploy]') }} |
| 58 | + uses: borales/actions-yarn@v4 |
| 59 | + with: |
| 60 | + cmd: install --prod |
| 61 | + |
| 62 | + - name: Installing utilities to generate additional files |
| 63 | + if: ${{ !contains(github.event.head_commit.message, '[skip deploy]') }} |
| 64 | + |
| 65 | + |
| 66 | + - name: Generate prisma clients |
| 67 | + if: ${{ !contains(github.event.head_commit.message, '[skip deploy]') }} |
| 68 | + run: npm run prisma:generate |
| 69 | + |
| 70 | + - name: Build Project Artifacts |
| 71 | + if: ${{ !contains(github.event.head_commit.message, '[skip deploy]') }} |
| 72 | + run: vercel build --token=${{ secrets.VERCEL_TOKEN }} --prod |
| 73 | + |
| 74 | + - name: Deploy Project Artifacts to Vercel |
| 75 | + if: ${{ !contains(github.event.head_commit.message, '[skip deploy]') }} |
| 76 | + run: vercel deploy --yes --prebuilt --prod --archive=tgz --token=${{ secrets.VERCEL_TOKEN }} |
| 77 | + |
| 78 | + e2e-tests: |
| 79 | + environment: vercel |
| 80 | + runs-on: ubuntu-latest |
| 81 | + needs: [build-and-deploy] |
| 82 | + |
| 83 | + steps: |
| 84 | + - name: Checkout code |
| 85 | + if: ${{ !contains(github.event.head_commit.message, '[skip e2e]') }} |
| 86 | + uses: actions/checkout@v4 |
| 87 | + |
| 88 | + - name: Set up Node.js |
| 89 | + if: ${{ !contains(github.event.head_commit.message, '[skip e2e]') }} |
| 90 | + uses: actions/setup-node@v4 |
| 91 | + with: |
| 92 | + node-version: '22.11.0' |
| 93 | + |
| 94 | + - name: Install dependencies |
| 95 | + if: ${{ !contains(github.event.head_commit.message, '[skip e2e]') }} |
| 96 | + uses: borales/actions-yarn@v4 |
| 97 | + with: |
| 98 | + cmd: install |
| 99 | + |
| 100 | + - name: Install Vercel CLI |
| 101 | + if: ${{ !contains(github.event.head_commit.message, '[skip e2e]') }} |
| 102 | + run: npm install --global vercel@latest |
| 103 | + |
| 104 | + - name: Pull Vercel Environment Information |
| 105 | + if: ${{ !contains(github.event.head_commit.message, '[skip e2e]') }} |
| 106 | + run: | |
| 107 | + vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }} |
| 108 | + cp -r .vercel/.env.production.local .env |
| 109 | + npx --yes tsx update-files-for-vercel.ts |
| 110 | +
|
| 111 | + - name: Generate prisma clients |
| 112 | + if: ${{ !contains(github.event.head_commit.message, '[skip e2e]') }} |
| 113 | + run: npm run prisma:generate |
| 114 | + |
| 115 | + - name: Run e2e-tests |
| 116 | + if: ${{ !contains(github.event.head_commit.message, '[skip e2e]') }} |
| 117 | + run: | |
| 118 | + export BASE_URL=https://nestjs-mod-fullstack.vercel.app |
| 119 | + export CLIENT_URL=https://nestjs-mod-fullstack.vercel.app |
| 120 | + export SERVER_URL=https://nestjs-mod-fullstack.vercel.app/api |
| 121 | + cp -r .vercel/.env.production.local .env |
| 122 | + npx --yes tsx update-files-for-vercel.ts |
| 123 | + npx playwright install chromium --with-deps |
| 124 | + npm run test:e2e |
| 125 | + - uses: actions/upload-artifact@v4 |
| 126 | + if: ${{ !contains(github.event.head_commit.message, '[skip e2e]') }} |
| 127 | + with: |
| 128 | + name: e2e-tests-videos |
| 129 | + path: apps/client-e2e/src/video/ |
0 commit comments