Skip to content

Run Cypress Tests

Run Cypress Tests #3

name: Run Cypress Tests
on:
schedule:
- cron: '0 4 * * 1' # Every Monday at 4:00 AM UTC
workflow_dispatch:
inputs:
target_env:
description: Target environment for Cypress run
required: true
default: staging
type: choice
options:
- staging
- prod
jobs:
cypress-run:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install dependencies
run: yarn install
- name: Copy production env file
if: (inputs.target_env || 'staging') == 'prod'
run: |
echo ${{ secrets.ENV_PRODUCTION }} | base64 -d > .env.prod
- name: Copy staging env file
if: (inputs.target_env || 'staging') == 'staging'
run: |
echo ${{ secrets.ENV_STAGING }} | base64 -d > .env.staging
- name: Build app
run: npx cross-env NODE_ENV=production APP_ENV=${{ inputs.target_env || 'staging' }} next build
- name: Run Cypress tests
uses: cypress-io/github-action@v6
with:
start: npx cross-env NODE_ENV=production APP_ENV=${{ inputs.target_env || 'staging' }} next start -p 3005
wait-on: 'http://localhost:3005'
wait-on-timeout: 300
command: yarn cypress:run
env:
NODE_ENV: production
APP_ENV: ${{ inputs.target_env || 'staging' }}
CYPRESS_BASE_URL: http://localhost:3005