Skip to content

Commit

Permalink
feat: add env input - #25 (#28)
Browse files Browse the repository at this point in the history
* feat: add env input ([cypress-io/actions#25](#25))

* Fix link in README based on comment
  • Loading branch information
prescottprue authored and bahmutov committed Nov 19, 2019
1 parent 51e2563 commit 1cad49d
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 0 deletions.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
8 changes: 8 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(' ')
Expand Down
8 changes: 8 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(' ')
Expand Down

0 comments on commit 1cad49d

Please sign in to comment.