How to Run k6 Cloud Tests From CI
k6 cloud run streams the test to Grafana Cloud k6, which supplies the load generators and returns a pass/fail exit code to CI.
Authenticate with K6_CLOUD_TOKEN, then run k6 cloud run script.js. The cloud service executes the test at scale and CI still gates on the thresholds in your script.
Steps
- Store the Grafana Cloud k6 token as a repo secret.
- Expose it as
K6_CLOUD_TOKEN(and the project id if needed). - Run
k6 cloud run k6-script.js; the exit code reflects your thresholds.
Workflow
.github/workflows/ci.yml
jobs:
cloud-load-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: grafana/setup-k6-action@v1
- name: Run in Grafana Cloud k6
env:
K6_CLOUD_TOKEN: ${{ secrets.K6_CLOUD_TOKEN }}
run: k6 cloud run k6-script.jsGotchas
- Cloud runs are metered by virtual user hours; a runaway matrix can burn the plan quickly.
- The runner only orchestrates; the load originates from cloud generators, so the runner size barely matters.
Related guides
How to Run k6 Load Tests in CI With GitHub ActionsRun a k6 load test in CI with the grafana/setup-k6-action, letting the script thresholds decide pass or fail…
How to Store and Trend Load Test ResultsStore load test results over time by streaming k6 metrics to Prometheus or InfluxDB and viewing trends in Gra…