diff --git a/.github/workflows/cypress-manual.yml b/.github/workflows/cypress-manual.yml index 34ca615..3a073e5 100644 --- a/.github/workflows/cypress-manual.yml +++ b/.github/workflows/cypress-manual.yml @@ -1,7 +1,18 @@ 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: @@ -19,20 +30,27 @@ jobs: - 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: yarn build:staging - env: - NODE_ENV: production - APP_ENV: staging + 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: yarn start:staging + 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 + command: yarn cypress:run env: NODE_ENV: production - APP_ENV: staging + APP_ENV: ${{ inputs.target_env || 'staging' }} CYPRESS_BASE_URL: http://localhost:3005