Run chaos experiments using GitHub Actions
Guide to run a chaos experiment using GitHub Actions
This tutorial explains how you can run Harness chaos experiments using GitHub Actions.
Create a chaos experiment in the Harness Chaos Engineering module. Execute this experiment to verify the configuration and ensure that the resilience probes are working as expected. The experiment ID and resilience score determined from this experiment run will be used to integrate the experiment with GitHub Actions.

chaos experiment with ID and resilience score
You will need the account scope details such as ACCOUNT_ID, ORG_ID, PROJECT_ID, and CHAOS_EXPERIMENT_ID. You can get these values from your session URL. For example,
The strings marked in asterisk are the account ID, org ID, project ID, and chaos experiment IDs respectively.
From your account profile page, generate an API key and copy it to a safe location (you will need it as a GitHub secret).
Create a GitHub Actions workflow file. Create a
.github/workflowsdirectory in your repository if it doesn't exist, and add a new workflow file (e.g.,chaos-experiment.yml) or add it in your existing workflow file.
Here's a sample workflow file:
The workflow above does the following:
Can be triggered by pushing to the main branch or manually through workflow_dispatch
Sets up environment variables from GitHub Variables and Secrets
Downloads and installs the HCE CLI
Runs and monitors the chaos experiment with specified parameters:
Account ID, Organization ID, and Project ID
Experiment ID and expected resilience score
300-second timeout
Non-interactive mode with monitoring enabled
To use this workflow:
Add the workflow file to your repository's
.github/workflowsdirectoryConfigure the required secret in your repository settings:
HARNESS_API_KEY: Your Harness API key
Configure the required variables in your repository settings:
HARNESS_ACCOUNT_ID: Your Harness account IDHARNESS_ORG_ID: Your Harness organization IDHARNESS_PROJECT_ID: Your Harness project IDHARNESS_EXPERIMENT_ID: Your Harness Chaos experiment IDHARNESS_EXPECTED_RES_SCORE: Your expected resilience score
The workflow will run automatically on:
Any push to the main branch
Manual trigger from the Actions tab
The workflow will fail if:
The chaos experiment fails to execute
The experiment's resilience score is below the expected threshold
The experiment execution exceeds the timeout (300 seconds)
Any step in the workflow encounters an error
Last updated
Was this helpful?