chore: fix vercel deployment step with explicit CLI token (#3) #9
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: CI-CD | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - dev | |
| - development | |
| pull_request: | |
| branches: | |
| - main | |
| - dev | |
| - development | |
| jobs: | |
| checks: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 30 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: npm | |
| cache-dependency-path: app/package-lock.json | |
| - name: Build frontend | |
| working-directory: app | |
| run: | | |
| npm ci | |
| npm run build | |
| - name: Setup Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Install backend dependencies | |
| working-directory: api | |
| run: | | |
| python -m pip install --no-input --upgrade pip | |
| pip install --no-input -r requirements.txt | |
| - name: Run backend tests | |
| working-directory: api | |
| run: python -m pytest -q | |
| deploy-development: | |
| if: github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/development' | |
| needs: checks | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 20 | |
| environment: | |
| name: development | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js for Vercel CLI | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| - name: Install Vercel CLI | |
| run: npm install -g vercel | |
| - name: Deploy frontend (Vercel) | |
| working-directory: app | |
| env: | |
| VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} | |
| VERCEL_SCOPE: ${{ secrets.VERCEL_SCOPE }} | |
| run: | | |
| npx vercel@25.1.0 deploy --yes --token "$VERCEL_TOKEN" --scope "$VERCEL_SCOPE" --name knowledge-copilot | |
| - name: Setup Node.js for Railway CLI | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| - name: Install Railway CLI | |
| run: npm install -g @railway/cli | |
| - name: Deploy API (Railway) | |
| env: | |
| RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN }} | |
| working-directory: api | |
| run: | | |
| if [ -z "${{ secrets.RAILWAY_DEV_ENVIRONMENT }}" ]; then | |
| echo "RAILWAY_DEV_ENVIRONMENT secret not configured." >&2 | |
| exit 1 | |
| fi | |
| railway up --service "${{ secrets.RAILWAY_SERVICE_NAME }}" \ | |
| --environment "${{ secrets.RAILWAY_DEV_ENVIRONMENT }}" \ | |
| --ci --detach | |
| deploy-production: | |
| if: github.ref == 'refs/heads/main' | |
| needs: checks | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 20 | |
| environment: | |
| name: production | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js for Vercel CLI | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| - name: Install Vercel CLI | |
| run: npm install -g vercel | |
| - name: Deploy frontend (Vercel) | |
| working-directory: app | |
| env: | |
| VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} | |
| VERCEL_SCOPE: ${{ secrets.VERCEL_SCOPE }} | |
| run: | | |
| npx vercel@25.1.0 deploy --yes --prod --confirm --token "$VERCEL_TOKEN" --scope "$VERCEL_SCOPE" --name knowledge-copilot | |
| - name: Setup Node.js for Railway CLI | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| - name: Install Railway CLI | |
| run: npm install -g @railway/cli | |
| - name: Deploy API (Railway) | |
| env: | |
| RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN }} | |
| working-directory: api | |
| run: | | |
| railway up --service "${{ secrets.RAILWAY_SERVICE_NAME }}" \ | |
| --environment production \ | |
| --ci --detach |