GitHub actions
The foreai-co/cj-action GitHub Action runs fore ai tests directly from your Github actions workflow.
Prerequisites
Add your fore ai service account key as a repository secret:
- Go to your GitHub repository → Settings → Secrets and variables → Actions
- Click New repository secret
- Name:
CRITICAL_JOURNEY_SERVICE_ACCOUNT_KEY - Value: paste your service account key from the fore ai Settings page
Run a single test
name: Run CJ Github Action
on: [push]
jobs:
my-job:
runs-on: ubuntu-latest
steps:
- name: Run Test
uses: foreai-co/cj-action@v1
id: run_cj
with:
test_id: 'my-test-id'
service_account_key: ${{ secrets.CRITICAL_JOURNEY_SERVICE_ACCOUNT_KEY }}
- name: Print result
run: echo "${{ steps.run_cj.outputs.result }}"
Run a test suite
name: Run CJ Github Action
on: [push]
jobs:
my-job:
runs-on: ubuntu-latest
steps:
- name: Run Test Suite
uses: foreai-co/cj-action@v1
id: run_cj
with:
test_suite_id: 'my-test-suite-id'
service_account_key: ${{ secrets.CRITICAL_JOURNEY_SERVICE_ACCOUNT_KEY }}
wait_timeout_seconds: 360 # = 6 minutes
# Override the website url using this optional field.
website_url_override: 'https://beta-dev.my-awesome.com/2'
# Override test parameters using this optional field. Provide valid json string.
params_override: '{ "param1" : "value1", "param2" : "value2" }'
- name: Print result
run: echo "${{ steps.run_cj.outputs.result }}"
Auto-create a GitHub issue on failure
When create_issue_on_failure is enabled, the action uses the default GITHUB_TOKEN provided automatically by GitHub Actions — no manual secret configuration is required. The created issue includes step traces, error details, test configuration, and a screenshot from the last executed step.
If your repository uses restrictive default permissions, add issues: write to the job permissions block.
name: Run CJ Github Action
on: [push]
jobs:
my-job:
runs-on: ubuntu-latest
permissions:
issues: write # Required to create GitHub issues on failure
steps:
- name: Run Test Suite
uses: foreai-co/cj-action@v1
id: run_cj
with:
test_suite_id: 'my-test-suite-id'
service_account_key: ${{ secrets.CRITICAL_JOURNEY_SERVICE_ACCOUNT_KEY }}
create_issue_on_failure: 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Print result
run: echo "${{ steps.run_cj.outputs.result }}"
Available inputs
| Input | Required | Default | Description |
|---|---|---|---|
test_id | No* | ID of the test to run. Provide either this or test_suite_id. | |
test_suite_id | No* | ID of the test suite to run. | |
service_account_key | Yes | Your fore ai service account key. | |
wait_timeout_seconds | No | 300 | Max seconds to wait for completion. Must be between 30 and 900. |
website_url_override | No | Override the base website URL used during test execution. | |
params_override | No | Override default parameter values. Must be a valid JSON string with string keys and values. | |
browser_type_override | No | chromium | Browser engine: chromium, firefox, or webkit. |
create_issue_on_failure | No | false | If true, creates a GitHub issue on test failure. |
* Either test_id or test_suite_id must be provided.
Output
| Output | Description |
|---|---|
result | Message with information about the status of the run. |