diff --git a/README.md b/README.md index e97c03782..a0eae5c96 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,28 @@ jobs: browser: chrome ``` +### Env + +Specify the env argument with `env` parameter + +```yml +name: Cypress tests +on: [push] +jobs: + cypress-run: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v1 + + - name: Cypress run with env + uses: cypress-io/github-action@v1 + with: + env: host=api.dev.local,port=4222 +``` + +For more information, visit [the Cypress command-line docs](https://on.cypress.io/command-line#cypress-run-env-lt-env-gt). + ### Record test results on Cypress Dashboard ```yml diff --git a/action.yml b/action.yml index dc7043c9b..8b5c02d06 100644 --- a/action.yml +++ b/action.yml @@ -7,6 +7,10 @@ inputs: description: 'Sends test results to Cypress Dashboard' required: false default: false + env: + description: 'Sets Cypress environment variables' + required: false + default: false runs: using: 'node12' main: 'dist/index.js' diff --git a/dist/index.js b/dist/index.js index db02d11c4..627e4bb0b 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1734,6 +1734,14 @@ const runTests = () => { cmd.push(browser) } + const envInput = core.getInput('env') + if (envInput) { + // TODO should env be quoted? + // If it is a JSON, it might have spaces + cmd.push('--env') + cmd.push(envInput) + } + console.log( 'Cypress test command: npx %s', cmd.join(' ') diff --git a/index.js b/index.js index f7660e311..34f2be010 100644 --- a/index.js +++ b/index.js @@ -291,6 +291,14 @@ const runTests = () => { cmd.push(browser) } + const envInput = core.getInput('env') + if (envInput) { + // TODO should env be quoted? + // If it is a JSON, it might have spaces + cmd.push('--env') + cmd.push(envInput) + } + console.log( 'Cypress test command: npx %s', cmd.join(' ')