|
1 |
| -README for Setup BrowserStack Test Environment |
| 1 | +# setup-env |
| 2 | + |
| 3 | +This action sets up the following environment variables in the runner environment. These environment variables shall be used in the tests for BrowserStack: |
| 4 | + |
| 5 | +1. `BROWSERSTACK_BUILD_NAME`: This environment variable is set on the basis of the input to `build-name` field. By default, the value will be decided based on the event, i.e. push, pull_request etc for the workflow: |
| 6 | + 1. `push` event: `[<Branch-Name>] Commit <commit-sha>: <commit-message> [Workflow: <Workflow-number>]` |
| 7 | + 2. `pull_request` event: `[<Branch-Name>] PR <PR-number>: <PR-title> [Workflow-number]` |
| 8 | + 3. `release` event: `[<Branch-Name>] Release <Release-tag>: <Release-name> [Workflow-number]` |
| 9 | + 4. Other events: `<Event-Name> [Workflow: <Workflow-number>]` |
| 10 | + |
| 11 | +2. `BROWSERSTACK_PROJECT_NAME`: This environment variable is set one basis of the input to `project-name` field. By default, i.e. if any input is not provided, the value will be set as the Repository Name. |
| 12 | +3. `BROWSERSTACK_USERNAME`: This environment variable's value is taken from the input to `username` field. Ideal way would be to pass the GitHub Secret as the input, i.e. `username: ${{ secrets.BROWSERSTACK_USERNAME }}`. |
| 13 | +4. `BROWSERSTACK_ACCESS_KEY`: This environment variable's value is taken from the input to `access-key` field. Ideal way would be to pass the GitHub Secret as the input, i.e. `access-key: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}`. |
| 14 | + |
| 15 | +## Prerequisites |
| 16 | +* This action does not have any prerequisites. |
| 17 | + |
| 18 | +## Usage |
| 19 | +``` |
| 20 | +- name: 'BrowserStack Env Setup' |
| 21 | + uses: 'browserstack/github-actions/setup-env@master' |
| 22 | + with: |
| 23 | + username: ${{ secrets.BROWSERSTACK_USERNAME }} |
| 24 | + access-key: ${{ secrets.BROWSERSTACK_ACCESS_KEY }} |
| 25 | + build-name: BUILD_INFO |
| 26 | + project-name: REPO_NAME |
| 27 | +``` |
| 28 | + |
| 29 | +or |
| 30 | + |
| 31 | +``` |
| 32 | +- name: 'BrowserStack Env Setup' |
| 33 | + uses: 'browserstack/github-actions/setup-env@master' |
| 34 | + with: |
| 35 | + username: ${{ secrets.BROWSERSTACK_USERNAME }} |
| 36 | + access-key: ${{ secrets.BROWSERSTACK_ACCESS_KEY }} |
| 37 | +``` |
| 38 | + |
| 39 | +## Inputs |
| 40 | +* `username`: (**Mandatory**) This is your BrowserStack Username. This should ideally be passed via a GitHub Secret as shown in the sample workflow above. |
| 41 | +* `access-key`: (**Mandatory**) This is your BrowserStack Access key that is required to access the BrowserStack device cloud. This should also ideally be passed via a GitHub Secret as shown in the sample workflow above. |
| 42 | +* `build-name`: (**Optional**) |
| 43 | + * You can pass any string that you want to set as the `BROWSERSTACK_BUILD_NAME`. E.g. `build-name: My Build Name Goes Here`. |
| 44 | + * You can also include your personalized string along with the keyword `BUILD_INFO` in the input: |
| 45 | + * `build-name: My String Goes Here - BUILD_INFO` |
| 46 | + * `build-name: BUILD_INFO - My String at the end` |
| 47 | + * `build-name: String at the Beginning - BUILD_INFO - String at the end` |
| 48 | + * The keyword `BUILD_INFO` will be replaced by the information based on the event of the workflow as described above for `BROWSERSTACK_BUILD_NAME` environment variable. |
| 49 | +* `project-name`: (**Optional**) |
| 50 | + * You can pass any string that you want to set as the `BROWSERSTACK_PROJECT_NAME`. E.g. `project-name: My Project Name Goes Here`. |
| 51 | + * You can also pass the keywork `REPO_NAME` as the input. This will set the Repository Name for the `BROWSERSTACK_PROJECT_NAME` environment variable. |
| 52 | + * If no input is provided, `REPO_NAME` will be considered as the default input. |
| 53 | + |
| 54 | +--- |
| 55 | +**NOTE** |
| 56 | +* This action is a prerequisite for any other BrowserStack related actions. |
| 57 | +* This action should be invoked prior to the execution of tests on BrowserStack to be able to utilise the environment variables in your tests. |
| 58 | +* You have to use the environment variables set by this action in your test script. |
| 59 | +--- |
0 commit comments