Search code examples
github-actionscypress

Adding environment variables to server with Cypress Github Action


I need to pass some environment variables to the server started in background by Cypress, eg under the start property below, as explained in the Cypress documentation:

  - name: Running e2e tests
    uses: cypress-io/github-action@v6
    with:
      start: sbt run
      command: npm run e2e:run-ci

If I use the env property, the variables are passed to the Cypress process, not the server process, eg:

  - name: Running e2e tests
    uses: cypress-io/github-action@v6
    with:
      start: sbt run
      command: npm run e2e:run-ci
      env: VAR=VAL

I also tried to replace the start value with "export VAR=VAL && sbt run" with no luck.


Solution

  • I found the answer here: cypress-io/github-action does not accept all environment variables

    I needed to declare the env variables at the job level.