Skip to main content

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:

  1. Go to your GitHub repository → SettingsSecrets and variablesActions
  2. Click New repository secret
  3. Name: CRITICAL_JOURNEY_SERVICE_ACCOUNT_KEY
  4. 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

InputRequiredDefaultDescription
test_idNo*ID of the test to run. Provide either this or test_suite_id.
test_suite_idNo*ID of the test suite to run.
service_account_keyYesYour fore ai service account key.
wait_timeout_secondsNo300Max seconds to wait for completion. Must be between 30 and 900.
website_url_overrideNoOverride the base website URL used during test execution.
params_overrideNoOverride default parameter values. Must be a valid JSON string with string keys and values.
browser_type_overrideNochromiumBrowser engine: chromium, firefox, or webkit.
create_issue_on_failureNofalseIf true, creates a GitHub issue on test failure.

* Either test_id or test_suite_id must be provided.

Output

OutputDescription
resultMessage with information about the status of the run.