Skip to content

Updates #2

Updates #2 #35

Workflow file for this run

name: CI/CD Pipeline for Next.js
on:
push:
branches: [main]
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: "20"
- name: Cache Node modules
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-node-
- name: Cache Next.js build
uses: actions/cache@v2
with:
path: .next/cache
key: ${{ runner.OS }}-nextjs-${{ hashFiles('**/*.js', '**/*.css') }}
restore-keys: |
${{ runner.OS }}-nextjs-
- name: Install Dependencies
run: npm ci
- name: Run Jest Tests
run: npm test
- name: Build Next.js Project
run: npm run build
- name: Start Next.js Application
run: npm run start &
env:
PORT: 3001
DATABASE_URL: ${{ secrets.TEST_DATABASE_URL }}
DIRECT_URL: ${{ secrets.TEST_DIRECT_URL }}
- name: Wait for Next.js Server
run: npx wait-on http://localhost:3001 --timeout 60000
- name: Cypress run
uses: cypress-io/github-action@v2
with:
headless: true
command: npm run cypress:run
wait-on: "http://localhost:3001"
wait-on-timeout: 60
env:
CYPRESS_BASE_URL: http://localhost:3001
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
TEST_STORE_ID: ${{ secrets.TEST_STORE_ID }}
TEST_EMAIL: ${{ secrets.TEST_EMAIL }}
TEST_PASSWORD: ${{ secrets.TEST_PASSWORD }}
TEST_PRODUCT_ID: ${{ secrets.TEST_PRODUCT_ID }}
TEST_USER_EMAIL: ${{ secrets.TEST_USER_EMAIL }}
TEST_USER_PASSWORD: ${{ secrets.TEST_USER_PASSWORD }}
TEST_USER_PRODUCT_ID: ${{ secrets.TEST_USER_PRODUCT_ID }}
NEXT_PUBLIC_TEST_APP_URL: ${{ secrets.NEXT_PUBLIC_TEST_APP_URL }}
deploy:
needs: build-and-test
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v2
- name: Deploy to Vercel
uses: amondnet/vercel-action@v20
with:
vercel-token: ${{ secrets.VERCEL_TOKEN }}
vercel-org-id: ${{ secrets.VERCEL_ORG_ID }}
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }}