@cypress/github-action 0.0.0-dev.5013

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,1983 @@
1
+ # cypress-io/github-action [![Action status][ci-badge]][ci-workflow] [![cypress][cloud-badge]][cloud-project] [![renovate-app badge][renovate-badge]][renovate-bot]
2
+
3
+ > [Cypress](https://www.cypress.io) based `cypress-io/github-action` runs [End-to-End](#end-to-end-testing) or [Component](#component-testing) tests in [GitHub Actions](https://docs.github.com/en/actions/) Continuous Integration (CI) workflows, optionally [recording](#record-test-results-on-cypress-cloud) to [Cypress Cloud](https://on.cypress.io/cloud-introduction)
4
+
5
+ ## Introduction
6
+
7
+ In addition to running Cypress tests, the action includes [dependency installation](#installation), [caching](#caching) and more:
8
+
9
+ | Function | Benefits |
10
+ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
11
+ | [Single-line call](#end-to-end-testing) | Simplified use by installing dependencies and running Cypress in one line of workflow code |
12
+ | [Build app](#build-app), [Start server](#start-server) and [Wait for server](#wait-on) options | Convenience of app, server and test coordination |
13
+ | [cypress run](https://docs.cypress.io/app/references/command-line#cypress-run) CLI type options | Improved readability with vertically listed workflow options |
14
+ | [Dependency installation](#installation) based on [npm](https://docs.npmjs.com/cli/configuring-npm/package-lock-json), [pnpm](https://pnpm.io/git#lockfiles) and [Yarn Classic](https://classic.yarnpkg.com/en/docs/yarn-lock) lock files | Reduced command complexity |
15
+ | [Caching](#caching) of Cypress binary and dependencies for [npm](https://docs.npmjs.com/cli/commands/npm-cache) and [Yarn Classic](https://classic.yarnpkg.com/lang/en/docs/cli/cache/) installations | Reduced download bandwidth requirements |
16
+ | [Job summary](#job-summary-title) | Fast access to results overview |
17
+ | [Docker](#docker-image) compatibility | Improved independence from [GitHub-hosted runner image](https://docs.github.com/en/actions/using-github-hosted-runners/using-github-hosted-runners/about-github-hosted-runners) version changes. Fixed Docker environments can be used. |
18
+ | [Recording](#record-test-results-on-cypress-cloud) to Cypress Cloud compatibility including [parallel](#parallel) execution | Improved interpretation of test results through [Cypress Cloud](https://on.cypress.io/cloud-introduction) |
19
+ | [Live examples](#examples) | Speeds up introduction and troubleshooting |
20
+ | [Yarn Modern](#yarn-modern) usage and cache examples | Extends usage beyond [Yarn Classic](https://classic.yarnpkg.com/) |
21
+ | [pnpm cache examples](#pnpm) | Reduced download bandwidth requirements for [pnpm](https://pnpm.io/) |
22
+ | [Debug](#debugging) enabled | Improved workflow troubleshooting |
23
+ | [Ping utility](#debugging-waiting-for-url-to-respond) | Improved server reachability troubleshooting |
24
+
25
+ The following examples demonstrate the actions' functions.
26
+
27
+ ## Examples
28
+
29
+ - [End-to-End](#end-to-end-testing) testing
30
+ - [Component](#component-testing) testing
31
+ - Select [action version](#action-version)
32
+ - Run tests in a given [browser](#browser)
33
+ - using [Chrome](#chrome)
34
+ - using [Chrome for Testing](#chrome-for-testing)
35
+ - using [Firefox](#firefox)
36
+ - using [Edge](#edge)
37
+ - using [headed mode](#headed)
38
+ - Using [Docker image](#docker-image)
39
+ - Specify [environment variables](#env)
40
+ - Specify [expose variables](#expose)
41
+ - Run only some [spec files](#specs)
42
+ - Test [project in subfolder](#project)
43
+ - [Record results](#record-test-results-on-cypress-cloud) on Cypress Cloud
44
+ - Getting [Git information](#git-information) environment variables
45
+ - Getting [PR and URL](#automatic-pr-number-and-url-detection) automatically
46
+ - Overwriting [Merge SHA into SHA](#merge-sha-into-sha) message
47
+ - Tag [recordings](#tag-recordings)
48
+ - Specify [auto cancel](#auto-cancel-after-failures) after failures
49
+ - Store [test artifacts](#artifacts) on GitHub
50
+ - [Quiet output](#quiet-flag)
51
+ - Set Cypress [config values](#config)
52
+ - Use specific [config file](#config-file)
53
+ - Run tests in [parallel](#parallel)
54
+ - Combine [Component and E2E](#component-and-e2e-testing) testing
55
+ - [Build app](#build-app) before running the tests
56
+ - [Start server](#start-server) before running the tests
57
+ - [Start multiple servers](#start-multiple-servers) before running the tests
58
+ - [Wait for server](#wait-on) to respond before running the tests
59
+ - Use [custom install command](#custom-install-command)
60
+ - Use [command prefix](#command-prefix)
61
+ - Use [custom test command](#custom-test-command)
62
+ - Pass [custom build id](#custom-build-id) when recording to Cypress Cloud
63
+ - Generate a [robust custom build id](#robust-custom-build-id) to allow re-running the workflow
64
+ - Use different [working-directory](#working-directory)
65
+ - Use [subfolders](#subfolders)
66
+ - Use [pnpm](#pnpm)
67
+ - Use [pnpm workspaces](#pnpm-workspaces)
68
+ - Use [Yarn Classic](#yarn-classic)
69
+ - Use [Yarn Modern](#yarn-modern)
70
+ - Use [Yarn Plug'n'Play](#yarn-plugnplay)
71
+ - Use [Yarn workspaces](#yarn-workspaces)
72
+ - Disable [package manager cache](#package-manager-cache-disable)
73
+ - Use [custom cache key](#custom-cache-key)
74
+ - Run tests on multiple [Node versions](#node-versions)
75
+ - Split [install and tests](#split-install-and-tests) into separate jobs
76
+ - Split [install and tests](#split-install-and-test-with-artifacts) with artifacts
77
+ - Use [custom install commands](#custom-install)
78
+ - Use [timeouts](#timeouts) to avoid hanging CI jobs
79
+ - Print [Cypress info](#print-cypress-info) like detected browsers
80
+ - Run [tests nightly](#nightly-tests) or on any schedule
81
+ - Specify [job summary title](#job-summary-title)
82
+ - Suppress [job summary](#suppress-job-summary)
83
+ - [More examples](#more-examples)
84
+
85
+ Examples contained in this repository, based on current Cypress versions, can be found in the [examples](./examples) directory.
86
+
87
+ Live examples, such as [example-basic.yml](.github/workflows/example-basic.yml) are shown together with a status badge. Click on the status badge to read the source code of the workflow, for example
88
+
89
+ [![End-to-End example](https://github.com/cypress-io/github-action/actions/workflows/example-basic.yml/badge.svg)](.github/workflows/example-basic.yml)
90
+
91
+ **Note:** this package assumes that [cypress](https://www.npmjs.com/package/cypress) is declared as a development dependency in the [package.json](https://docs.npmjs.com/creating-a-package-json-file) file. The [cypress npm module](https://www.npmjs.com/package/cypress) is required to run Cypress via its [Module API](https://on.cypress.io/module-api).
92
+
93
+ ### End-to-End Testing
94
+
95
+ ```yml
96
+ name: End-to-end tests
97
+ on: push
98
+ jobs:
99
+ cypress-run:
100
+ runs-on: ubuntu-26.04
101
+ steps:
102
+ - name: Checkout
103
+ uses: actions/checkout@v7
104
+ # Install dependencies with caching
105
+ # and run all Cypress tests
106
+ - name: Cypress run
107
+ uses: cypress-io/github-action@v7
108
+ ```
109
+
110
+ [![End-to-End example](https://github.com/cypress-io/github-action/actions/workflows/example-basic.yml/badge.svg)](.github/workflows/example-basic.yml)
111
+
112
+ The workflow file [example-basic.yml](.github/workflows/example-basic.yml) shows how Cypress runs on GH Actions using Ubuntu (`22.04` and `24.04`), Windows, and macOS without additional OS dependencies necessary.
113
+
114
+ This workflow uses the default [test type](https://on.cypress.io/choosing-testing-type) of [End-to-End (E2E) Testing](https://on.cypress.io/app/core-concepts/testing-types#What-is-E2E-Testing). Alternatively, [Component Testing](https://on.cypress.io/app/core-concepts/testing-types#What-is-Component-Testing) can be utilized by referencing the [Component Testing](#component-testing) section below.
115
+
116
+ ### Component Testing
117
+
118
+ To use [Cypress Component Testing](https://on.cypress.io/component-testing) add `component: true`
119
+
120
+ ```yml
121
+ name: Component tests
122
+ on: push
123
+ jobs:
124
+ cypress-run:
125
+ runs-on: ubuntu-26.04
126
+ steps:
127
+ - name: Checkout
128
+ uses: actions/checkout@v7
129
+ - name: Cypress run
130
+ uses: cypress-io/github-action@v7
131
+ with:
132
+ component: true
133
+ ```
134
+
135
+ [![Component Testing example](https://github.com/cypress-io/github-action/actions/workflows/example-component-test.yml/badge.svg)](.github/workflows/example-component-test.yml)
136
+
137
+ See the example project [component-tests](examples/component-tests/) and the [example-component-test.yml](.github/workflows/example-component-test.yml) workflow for more details.
138
+
139
+ ### Action version
140
+
141
+ **Best practice:**
142
+
143
+ Our examples specify using branch `v7` which is the action's recommended major version:
144
+
145
+ ```yml
146
+ - name: Cypress run
147
+ uses: cypress-io/github-action@v7
148
+ ```
149
+
150
+ When using `cypress-io/github-action@v7` from your workflow file, you will automatically use the latest [tag](https://github.com/cypress-io/github-action/tags) from branch `v7`.
151
+
152
+ Alternatively, to mitigate unforeseen breaks, bind to a specific [tag](https://github.com/cypress-io/github-action/tags), for example:
153
+
154
+ ```yml
155
+ - name: Cypress run
156
+ uses: cypress-io/github-action@v7.0.0
157
+ ```
158
+
159
+ The changes associated with each tag are shown under GitHub's [releases](https://github.com/cypress-io/github-action/releases) list. Refer also to the [CHANGELOG](./CHANGELOG.md) for an overview of major changes.
160
+
161
+ The workflows in the [examples](./examples/) directory use the latest commit from the repo's current branch. This allows all tests to run in CI before release. If you copy any of the examples to your own repo, you should replace `./` and specify instead the action and version as described above.
162
+
163
+ ```yml
164
+ - uses: ./ # replace with cypress-io/github-action@v7
165
+ ```
166
+
167
+ ### Browser
168
+
169
+ Specify the browser name or path with the `browser` parameter.
170
+
171
+ The default browser can be set as a [Browser](https://docs.cypress.io/app/references/configuration#Browser) configuration option `defaultBrowser`.
172
+ If no `browser` parameter is specified and `defaultBrowser` is also undefined,
173
+ the built-in [Electron browser](https://on.cypress.io/guides/guides/launching-browsers#Electron-Browser) is used.
174
+
175
+ [cypress@16.0.0](https://docs.cypress.io/app/references/changelog#16-0-0) deprecated the Electron browser and describes the plan to remove it in a future major version of Cypress.
176
+
177
+ Each of the [examples](./examples/) directories in this repo sets `defaultBrowser` to `chrome`.
178
+
179
+ ### Chrome
180
+
181
+ ```yml
182
+ name: Chrome
183
+ on: push
184
+ jobs:
185
+ chrome:
186
+ runs-on: ubuntu-26.04
187
+ name: E2E on Chrome
188
+ steps:
189
+ - uses: actions/checkout@v7
190
+ - uses: cypress-io/github-action@v7
191
+ with:
192
+ browser: chrome
193
+ ```
194
+
195
+ [![Chrome example](https://github.com/cypress-io/github-action/actions/workflows/example-chrome.yml/badge.svg)](.github/workflows/example-chrome.yml)
196
+
197
+ ### Chrome for Testing
198
+
199
+ To install [Google Chrome for Testing](https://developer.chrome.com/blog/chrome-for-testing/)
200
+ use [browser-actions/setup-chrome](https://github.com/browser-actions/setup-chrome).
201
+ Refer to [Chrome for Testing availability](https://googlechromelabs.github.io/chrome-for-testing/) for current versions
202
+ or [JSON API endpoints](https://github.com/GoogleChromeLabs/chrome-for-testing#json-api-endpoints)
203
+ for all available versions.
204
+
205
+ ```yml
206
+ name: Chrome for Testing
207
+ on: push
208
+ jobs:
209
+ chrome:
210
+ runs-on: ubuntu-26.04
211
+ name: E2E on Chrome for Testing
212
+ steps:
213
+ - uses: actions/checkout@v7
214
+ - uses: browser-actions/setup-chrome@v2
215
+ - uses: cypress-io/github-action@v7
216
+ with:
217
+ browser: chrome-for-testing
218
+ ```
219
+
220
+ [![Chrome for Testing example](https://github.com/cypress-io/github-action/actions/workflows/example-chrome-for-testing.yml/badge.svg)](.github/workflows/example-chrome-for-testing.yml)
221
+
222
+ ### Firefox
223
+
224
+ ```yml
225
+ name: Firefox
226
+ on: push
227
+ jobs:
228
+ firefox:
229
+ runs-on: ubuntu-26.04
230
+ name: E2E on Firefox
231
+ steps:
232
+ - uses: actions/checkout@v7
233
+ - uses: cypress-io/github-action@v7
234
+ with:
235
+ browser: firefox
236
+ ```
237
+
238
+ [![Firefox example](https://github.com/cypress-io/github-action/actions/workflows/example-firefox.yml/badge.svg)](.github/workflows/example-firefox.yml)
239
+
240
+ ### Edge
241
+
242
+ ```yml
243
+ name: Edge
244
+ on: push
245
+ jobs:
246
+ edge:
247
+ runs-on: ubuntu-26.04
248
+ name: E2E on Edge
249
+ steps:
250
+ - uses: actions/checkout@v7
251
+ - uses: cypress-io/github-action@v7
252
+ with:
253
+ browser: edge
254
+ ```
255
+
256
+ [![Edge example](https://github.com/cypress-io/github-action/actions/workflows/example-edge.yml/badge.svg)](.github/workflows/example-edge.yml)
257
+
258
+ ### Headed
259
+
260
+ Run the browser in headed mode - as of Cypress v8.0 the `cypress run` command executes tests in `headless` mode by default
261
+
262
+ ```yml
263
+ name: Chrome headed
264
+ on: push
265
+ jobs:
266
+ cypress-run:
267
+ runs-on: ubuntu-26.04
268
+ steps:
269
+ - uses: actions/checkout@v7
270
+ - uses: cypress-io/github-action@v7
271
+ with:
272
+ browser: chrome
273
+ headed: true
274
+ ```
275
+
276
+ ### Docker image
277
+
278
+ You can run the action in a Docker container.
279
+
280
+ ```yml
281
+ name: Test in Docker
282
+ on: push
283
+ jobs:
284
+ cypress-run:
285
+ runs-on: ubuntu-26.04
286
+ # Cypress Docker image from https://hub.docker.com/r/cypress
287
+ # with browsers pre-installed
288
+ container:
289
+ image: cypress/browsers:latest
290
+ options: --user 1001
291
+ steps:
292
+ - uses: actions/checkout@v7
293
+ - uses: cypress-io/github-action@v7
294
+ with:
295
+ browser: chrome
296
+ ```
297
+
298
+ Replace the `latest` tag with a specific version image tag from [`cypress/browsers` on Docker Hub](https://hub.docker.com/r/cypress/browsers/tags) to avoid breaking changes when new images are released (especially when they include new major versions of Node.js).
299
+
300
+ Include `options: --user 1001` to avoid permissions issues.
301
+
302
+ When using [cypress/included](https://github.com/cypress-io/cypress-docker-images/tree/master/included) Docker images, set the environment variable `CYPRESS_INSTALL_BINARY=0` to suppress saving the Cypress binary cache, otherwise cache restore errors may occur. The example below shows how to do this:
303
+
304
+ ```yml
305
+ name: Test with Docker cypress/included
306
+ on: push
307
+ jobs:
308
+ cypress-run:
309
+ runs-on: ubuntu-26.04
310
+ container:
311
+ # Cypress Docker image from https://hub.docker.com/r/cypress/included
312
+ # with Cypress globally pre-installed
313
+ image: cypress/included:latest
314
+ options: --user 1001
315
+ steps:
316
+ - uses: actions/checkout@v7
317
+ - uses: cypress-io/github-action@v7
318
+ with:
319
+ browser: chrome
320
+ env:
321
+ CYPRESS_INSTALL_BINARY: 0
322
+ ```
323
+
324
+ Refer to [cypress-io/cypress-docker-images](https://github.com/cypress-io/cypress-docker-images) for further information about using Cypress Docker images. Cypress offers the [Cypress Docker Factory](https://github.com/cypress-io/cypress-docker-images/tree/master/factory) to generate additional Docker images with selected components and versions.
325
+
326
+ [![Docker example](https://github.com/cypress-io/github-action/actions/workflows/example-docker.yml/badge.svg)](.github/workflows/example-docker.yml)
327
+
328
+ ### Env
329
+
330
+ To pass an environment variable to Cypress <15.10.0 use the action's `env` parameter.
331
+ In Cypress 15.10.0 and above, the `env` is specified for use with secret environment variables.
332
+ It is replaced with the [expose](#expose) action parameter for public, non-sensitive environment variables.
333
+
334
+ ```yml
335
+ name: Cypress tests
336
+ on: push
337
+ jobs:
338
+ cypress-run:
339
+ runs-on: ubuntu-26.04
340
+ steps:
341
+ - name: Checkout
342
+ uses: actions/checkout@v7
343
+
344
+ - name: Cypress run with env
345
+ uses: cypress-io/github-action@v7
346
+ with:
347
+ env: host=api.dev.local,port=4222
348
+ ```
349
+
350
+ When passing the environment variables this way, unfortunately due to GitHub Actions syntax, the variables should be listed in a single line, which can be hard to read. As an alternative, you can use the step's `env` block where every variable can be set on its own line. In this case, you should prefix every variable with `CYPRESS_` because such variables [are loaded by Cypress automatically](https://docs.cypress.io/app/guides/environment-variables). The above code example is equivalent to:
351
+
352
+ ```yml
353
+ name: Cypress tests
354
+ on: push
355
+ jobs:
356
+ cypress-run:
357
+ runs-on: ubuntu-26.04
358
+ steps:
359
+ - name: Checkout
360
+ uses: actions/checkout@v7
361
+
362
+ - name: Cypress run with env
363
+ uses: cypress-io/github-action@v7
364
+ env:
365
+ CYPRESS_host: api.dev.local
366
+ CYPRESS_port: 4222
367
+ ```
368
+
369
+ For more examples, see the workflows below, using environment variables for [recording](#record-test-results-on-cypress-cloud).
370
+
371
+ [![Env example](https://github.com/cypress-io/github-action/actions/workflows/example-env.yml/badge.svg)](.github/workflows/example-env.yml)
372
+
373
+ ### Expose
374
+
375
+ Specify the expose argument with `expose` parameter. Expose variables are for non-sensitive, public config values that are synchronous and exposed to the browser (requires Cypress 15.10.0 or later).
376
+
377
+ ```yml
378
+ name: Cypress tests
379
+ on: push
380
+ jobs:
381
+ cypress-run:
382
+ runs-on: ubuntu-26.04
383
+ steps:
384
+ - name: Checkout
385
+ uses: actions/checkout@v7
386
+
387
+ - name: Cypress run with expose
388
+ uses: cypress-io/github-action@v7
389
+ with:
390
+ expose: host=api.dev.local,port=4222
391
+ ```
392
+
393
+ For more information, see [Cypress.expose()](https://docs.cypress.io/api/cypress-api/expose) in the Cypress documentation.
394
+
395
+ [![Expose example](https://github.com/cypress-io/github-action/actions/workflows/example-expose.yml/badge.svg)](.github/workflows/example-expose.yml)
396
+
397
+ ### Specs
398
+
399
+ Specify the [spec files to run](https://docs.cypress.io/guides/guides/command-line.html#cypress-run-spec-lt-spec-gt) with `spec` parameter
400
+
401
+ ```yml
402
+ name: Cypress tests
403
+ on: push
404
+ jobs:
405
+ cypress-run:
406
+ name: Cypress run
407
+ runs-on: ubuntu-26.04
408
+ steps:
409
+ - name: Checkout
410
+ uses: actions/checkout@v7
411
+
412
+ - name: Cypress run
413
+ uses: cypress-io/github-action@v7
414
+ with:
415
+ spec: cypress/e2e/spec1.cy.js
416
+ ```
417
+
418
+ You can pass multiple specs and wild card patterns using multi-line parameter, see [example-config.yml](.github/workflows/example-config.yml):
419
+
420
+ ```yml
421
+ spec: |
422
+ cypress/e2e/spec-a.cy.js
423
+ cypress/**/*-b.cy.js
424
+ ```
425
+
426
+ For more information, visit [the Cypress command-line docs](https://on.cypress.io/command-line#cypress-run-env-lt-env-gt).
427
+
428
+ ### Project
429
+
430
+ Specify the [project to run](https://on.cypress.io/command-line#cypress-run-project-lt-project-path-gt) with the `project` parameter
431
+
432
+ ```yml
433
+ name: Cypress tests
434
+ on: push
435
+ jobs:
436
+ cypress-run:
437
+ name: Cypress run
438
+ runs-on: ubuntu-26.04
439
+ steps:
440
+ - name: Checkout
441
+ uses: actions/checkout@v7
442
+ - name: Cypress run
443
+ uses: cypress-io/github-action@v7
444
+ with:
445
+ project: ./test-subdirectory
446
+ ```
447
+
448
+ The `project` parameter may be used to pass on the location of a sub-directory containing a Cypress configuration file and Cypress tests specs. For more information, visit [the Cypress command-line docs](https://on.cypress.io/command-line#cypress-run-project-lt-project-path-gt).
449
+
450
+ A package manager lock file, including Cypress, must be provided in the root of the repository so that the action is able to [install Cypress](#installation).
451
+
452
+ If the parameter [working-directory](#working-directory) is also defined, then this is the location to place the package manager lock file, and the project directory would be a subdirectory of the [working-directory](#working-directory). The `project` parameter location may not be above the level of a specified [working-directory](#working-directory) in the file hierarchy.
453
+
454
+ ### Record test results on Cypress Cloud
455
+
456
+ By setting the parameter `record` to `true`, you can record your test results into [Cypress Cloud](https://on.cypress.io/cloud-introduction). Read the [Cypress Cloud setup](https://on.cypress.io/cloud/get-started/setup) documentation to learn how to sign up to Cypress Cloud, to create and set up a [Cloud project](https://on.cypress.io/cloud/account-management/projects) to get the required `projectId` and record key for recording.
457
+
458
+ - The `projectId` can either be stored in the [Cypress Configuration File](https://on.cypress.io/app/references/configuration#Configuration-File) or passed to the action as an environment variable `CYPRESS_PROJECT_ID`. In the example below, it is retrieved from a [GitHub secret](https://docs.github.com/en/actions/security-for-github-actions/security-guides/using-secrets-in-github-actions) variable.
459
+
460
+ - The record key is passed to the action as an environment variable `CYPRESS_RECORD_KEY`. We recommend you treat this value as sensitive and store it as a [GitHub secret](https://docs.github.com/en/actions/security-for-github-actions/security-guides/using-secrets-in-github-actions) variable, so that access is restricted.
461
+
462
+ - We recommend passing the `GITHUB_TOKEN` secret (created by the GH Action automatically) as an environment variable. This will allow correctly identifying every build and avoid confusion when re-running a build.
463
+
464
+ ```yml
465
+ name: Cypress tests
466
+ on: push
467
+ jobs:
468
+ cypress-run:
469
+ name: Cypress run
470
+ runs-on: ubuntu-26.04
471
+ steps:
472
+ - name: Checkout
473
+ uses: actions/checkout@v7
474
+
475
+ - name: Cypress run
476
+ uses: cypress-io/github-action@v7
477
+ with:
478
+ record: true
479
+ env:
480
+ # pass the Cypress Cloud project ID as an environment variable or store it in the Cypress configuration file
481
+ CYPRESS_PROJECT_ID: ${{ secrets.EXAMPLE_PROJECT_ID }}
482
+ # pass the Cypress Cloud record key as an environment variable
483
+ CYPRESS_RECORD_KEY: ${{ secrets.EXAMPLE_RECORDING_KEY }}
484
+ # pass GitHub token to allow accurately detecting a build vs a re-run build
485
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
486
+ ```
487
+
488
+ [![recording example](https://github.com/cypress-io/github-action/actions/workflows/example-recording.yml/badge.svg)](.github/workflows/example-recording.yml)
489
+
490
+ ### Git information
491
+
492
+ Cypress uses the [@cypress/commit-info](https://github.com/cypress-io/commit-info) package to associate Git details (branch, commit message, author) with each run. It typically uses Git commands, expecting a .git folder. In Docker or similar environments where .git is absent, or if you need different data in the Cypress Cloud, Git information can be passed via custom environment variables.
493
+
494
+ ```yml
495
+ name: Cypress tests
496
+ on: push
497
+ jobs:
498
+ cypress-run:
499
+ name: Cypress run
500
+ runs-on: ubuntu-26.04
501
+ steps:
502
+ - name: Checkout
503
+ uses: actions/checkout@v7
504
+ - name: Cypress run
505
+ uses: cypress-io/github-action@v7
506
+ with:
507
+ record: true
508
+ env:
509
+ # Get the short ref name of the branch that triggered the workflow run
510
+ COMMIT_INFO_BRANCH: ${{ github.ref_name }}
511
+ CYPRESS_RECORD_KEY: ${{ secrets.EXAMPLE_RECORDING_KEY }}
512
+ ```
513
+
514
+ Please refer to the [Cypress Cloud Git information environment variables](https://on.cypress.io/guides/continuous-integration/introduction#Git-information) section in our documentation for more examples.
515
+
516
+ Please refer to the [default GitHub environment variables](https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables) for additional GitHub examples.
517
+
518
+ ### Automatic PR number and URL detection
519
+
520
+ When recording runs to Cypress Cloud, the PR number and URL can be automatically detected if you pass `GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}`
521
+ via the workflow `env`. When set, this value enables the Action to perform additional logic that grabs the related PR number and URL (if they
522
+ exist) and sets them in the environment variables `CYPRESS_PULL_REQUEST_ID` and `CYPRESS_PULL_REQUEST_URL`, respectively.
523
+
524
+ - See Cypress' documentation on [CI Build Information](https://on.cypress.io/guides/continuous-integration/introduction#CI-Build-Information)
525
+
526
+ Example workflow using the variables:
527
+
528
+ ```yml
529
+ name: Example echo PR number and URL
530
+ on: push
531
+ jobs:
532
+ cypress-run:
533
+ runs-on: ubuntu-26.04
534
+ steps:
535
+ - name: Checkout
536
+ uses: actions/checkout@v7
537
+ - name: Cypress run
538
+ uses: cypress-io/github-action@v7
539
+ with:
540
+ record: true
541
+ - run: echo "PR number is $CYPRESS_PULL_REQUEST_ID"
542
+ - run: echo "PR URL is $CYPRESS_PULL_REQUEST_URL"
543
+ env:
544
+ CYPRESS_RECORD_KEY: ${{ secrets.EXAMPLE_RECORDING_KEY }}
545
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
546
+ ```
547
+
548
+ #### Triggering event: `pull_request`/`pull_request_target`
549
+
550
+ For either of these events, we set `CYPRESS_PULL_REQUEST_ID` and `CYPRESS_PULL_REQUEST_URL` to that of the PR number and URL, respectively, of the
551
+ PR that triggered the workflow.
552
+
553
+ #### Triggering event: `push`
554
+
555
+ When a commit on a branch without a PR is made, the Cypress GitHub Action checks to see if the commit that triggered the workflow has a
556
+ related PR. If the commit exists in any other PRs, it's considered a related PR. When there are related PRs, we grab the first related PR
557
+ and use that PR's number and URL for `CYPRESS_PULL_REQUEST_ID` and `CYPRESS_PULL_REQUEST_URL`, respectively.
558
+
559
+ If no related PR is detected, `CYPRESS_PULL_REQUEST_ID` and `CYPRESS_PULL_REQUEST_URL` will be undefined.
560
+
561
+ ### Merge SHA into SHA
562
+
563
+ We recommend using the action with `on: push` rather than `on: pull_request` or `on: merge_group` for more accurate commit information in Cypress Cloud. When running on pull_request or merge_group, the commit message defaults to "merge SHA into SHA". You can overwrite the commit message sent to Cypress Cloud by setting an environment variable.
564
+
565
+ ```yml
566
+ name: Cypress tests
567
+ on: push
568
+ jobs:
569
+ cypress-run:
570
+ name: Cypress run
571
+ runs-on: ubuntu-26.04
572
+ steps:
573
+ - name: Checkout
574
+ uses: actions/checkout@v7
575
+
576
+ - name: Cypress run
577
+ uses: cypress-io/github-action@v7
578
+ with:
579
+ record: true
580
+ env:
581
+ # overwrite commit message sent to Cypress Cloud
582
+ COMMIT_INFO_MESSAGE: ${{github.event.pull_request.title}}
583
+ # re-enable PR comment bot
584
+ COMMIT_INFO_SHA: ${{github.event.pull_request.head.sha}}
585
+ CYPRESS_RECORD_KEY: ${{ secrets.EXAMPLE_RECORDING_KEY }}
586
+ ```
587
+
588
+ See [issue 124](https://github.com/cypress-io/github-action/issues/124#issuecomment-1076826988) for details.
589
+
590
+ ### Tag recordings
591
+
592
+ You can pass a single or multiple tags when recording a run. For example
593
+
594
+ ```yml
595
+ name: tags
596
+ on: push
597
+ jobs:
598
+ cypress-run:
599
+ runs-on: ubuntu-26.04
600
+ # let's make sure our "app" works on several versions of Node
601
+ strategy:
602
+ matrix:
603
+ node:
604
+ - 22
605
+ - 24
606
+ - 26
607
+ name: E2E on Node v${{ matrix.node }}
608
+ steps:
609
+ - name: Checkout
610
+ uses: actions/checkout@v7
611
+ - name: Install Node.js
612
+ uses: actions/setup-node@v7
613
+ with:
614
+ node-version: ${{ matrix.node }}
615
+ - run: node -v
616
+
617
+ - name: Cypress run
618
+ uses: cypress-io/github-action@v7
619
+ with:
620
+ record: true
621
+ tag: node-${{ matrix.node }}
622
+ env:
623
+ CYPRESS_RECORD_KEY: ${{ secrets.EXAMPLE_RECORDING_KEY }}
624
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
625
+ ```
626
+
627
+ The recording will have tags as labels on the run.
628
+
629
+ ![Tags](images/tags.png)
630
+
631
+ You can pass multiple tags using commas like `tag: node-22,nightly,staging`.
632
+
633
+ ### Auto cancel after failures
634
+
635
+ Specify the number of failed tests that will cancel a run when using the [Cypress Cloud Auto Cancellation](https://docs.cypress.io/cloud/features/smart-orchestration/run-cancellation) feature.
636
+
637
+ This feature requires Cypress 12.6.0 or later and a [Cypress Cloud Business or Enterprise](https://www.cypress.io/cloud/) account.
638
+
639
+ ```yml
640
+ name: Cypress E2E Tests
641
+ on: push
642
+ jobs:
643
+ cypress-run:
644
+ runs-on: ubuntu-26.04
645
+ name: E2E
646
+ steps:
647
+ - name: Checkout
648
+ uses: actions/checkout@v7
649
+
650
+ - name: Cypress run
651
+ uses: cypress-io/github-action@v7
652
+ with:
653
+ record: true
654
+ # Cancel the run after 2 failed tests
655
+ auto-cancel-after-failures: 2
656
+ env:
657
+ CYPRESS_RECORD_KEY: ${{ secrets.EXAMPLE_RECORDING_KEY }}
658
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
659
+ ```
660
+
661
+ See [Auto Cancellation](https://docs.cypress.io/cloud/features/smart-orchestration/run-cancellation) for more information.
662
+
663
+ ### Artifacts
664
+
665
+ If you don't record the test run on Cypress Cloud, you can still store generated videos and screenshots as CI artifacts. See the workflow example below.
666
+
667
+ ```yml
668
+ name: Artifacts
669
+ on: push
670
+ jobs:
671
+ cypress-run:
672
+ runs-on: ubuntu-26.04
673
+ name: Artifacts
674
+ steps:
675
+ - uses: actions/checkout@v7
676
+ - uses: cypress-io/github-action@v7
677
+ # after the test run completes store videos and any screenshots
678
+ - uses: actions/upload-artifact@v7
679
+ # add the line below to store screenshots only on failures
680
+ # if: failure()
681
+ with:
682
+ name: cypress-screenshots
683
+ path: cypress/screenshots
684
+ if-no-files-found: ignore # 'warn' or 'error' are also available, defaults to `warn`
685
+ - uses: actions/upload-artifact@v7
686
+ with:
687
+ name: cypress-videos
688
+ path: cypress/videos
689
+ if-no-files-found: ignore # 'warn' or 'error' are also available, defaults to `warn`
690
+ ```
691
+
692
+ ### Quiet flag
693
+
694
+ You can provide `quiet` flag for cypress run to silence any Cypress specific output from stdout
695
+
696
+ ```yml
697
+ name: example-quiet
698
+ on: push
699
+ jobs:
700
+ cypress-run:
701
+ runs-on: ubuntu-26.04
702
+ steps:
703
+ - name: Checkout
704
+ uses: actions/checkout@v7
705
+ # Install dependencies with caching
706
+ # and run all Cypress tests with `quiet` parameter
707
+ - name: Cypress run
708
+ uses: cypress-io/github-action@v7
709
+ with:
710
+ working-directory: examples/quiet
711
+ quiet: true
712
+ ```
713
+
714
+ [![example-quiet](https://github.com/cypress-io/github-action/actions/workflows/example-quiet.yml/badge.svg)](.github/workflows/example-quiet.yml)
715
+
716
+ ### Config
717
+
718
+ Specify [configuration](https://docs.cypress.io/guides/references/configuration.html) values with `config` parameter
719
+
720
+ ```yml
721
+ name: Cypress tests
722
+ on: push
723
+ jobs:
724
+ cypress-run:
725
+ name: Cypress run
726
+ runs-on: ubuntu-26.04
727
+ steps:
728
+ - name: Checkout
729
+ uses: actions/checkout@v7
730
+
731
+ - name: Cypress run
732
+ uses: cypress-io/github-action@v7
733
+ with:
734
+ config: pageLoadTimeout=100000,baseUrl=http://localhost:3000
735
+ ```
736
+
737
+ [![example-config](https://github.com/cypress-io/github-action/actions/workflows/example-config.yml/badge.svg)](.github/workflows/example-config.yml)
738
+
739
+ ### Config File
740
+
741
+ Specify the path to your [Configuration File](https://on.cypress.io/guides/references/configuration#Configuration-File) with `config-file` parameter
742
+
743
+ ```yml
744
+ name: Cypress tests
745
+ on: push
746
+ jobs:
747
+ cypress-run:
748
+ name: Cypress run
749
+ runs-on: ubuntu-26.04
750
+ steps:
751
+ - name: Checkout
752
+ uses: actions/checkout@v7
753
+
754
+ - name: Cypress run
755
+ uses: cypress-io/github-action@v7
756
+ with:
757
+ config-file: cypress.config-alternate.js
758
+ ```
759
+
760
+ [![example-config](https://github.com/cypress-io/github-action/actions/workflows/example-config.yml/badge.svg)](.github/workflows/example-config.yml)
761
+
762
+ ### Parallel
763
+
764
+ **Note:** Cypress parallelization requires a [Cypress Cloud](https://on.cypress.io/cloud-introduction) account.
765
+
766
+ You can spin multiple jobs running in parallel using the `strategy: matrix` argument.
767
+ Just add more dummy items to the `recording-job: [1, 2, ...]` array to create multiple job runs.
768
+ Then use `record` and `parallel` parameters to [load balance tests](https://on.cypress.io/parallelization).
769
+
770
+ ```yml
771
+ name: Parallel Cypress Tests
772
+ on: push
773
+ jobs:
774
+ test:
775
+ name: Cypress run
776
+ runs-on: ubuntu-26.04
777
+ strategy:
778
+ # when one test fails, DO NOT cancel the other
779
+ # containers, because this will kill Cypress processes
780
+ # leaving Cypress Cloud hanging ...
781
+ # https://github.com/cypress-io/github-action/issues/48
782
+ fail-fast: false
783
+ matrix:
784
+ # run 3 copies of the current job in parallel
785
+ recording-job: [1, 2, 3]
786
+ container:
787
+ image: cypress/browsers:latest
788
+ options: --user 1001
789
+ steps:
790
+ - name: Checkout
791
+ uses: actions/checkout@v7
792
+
793
+ # because of "record" and "parallel" parameters
794
+ # these jobs will load balance all found tests among themselves
795
+ - name: Cypress run
796
+ uses: cypress-io/github-action@v7
797
+ with:
798
+ record: true
799
+ parallel: true
800
+ group: 'Actions example'
801
+ env:
802
+ # pass the Cypress Cloud record key as an environment variable
803
+ CYPRESS_RECORD_KEY: ${{ secrets.EXAMPLE_RECORDING_KEY }}
804
+ # Recommended: passing the GitHub token lets this action correctly
805
+ # determine the unique run id necessary to re-run the checks
806
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
807
+ ```
808
+
809
+ ![Parallel run](images/parallel.png)
810
+
811
+ The Cypress GitHub Action does not spawn or create any additional jobs -
812
+ it only links the multiple jobs spawned using the matrix strategy into a single logical Cypress Cloud run
813
+ where it splits the specs amongst the machines.
814
+ See the [Cypress Cloud Smart Orchestration](https://docs.cypress.io/cloud/features/smart-orchestration/overview/) guide
815
+ for a detailed explanation.
816
+
817
+ If you use the GitHub Actions facility for [Re-running workflows and jobs](https://docs.github.com/en/actions/managing-workflow-runs/re-running-workflows-and-jobs), note that [Re-running failed jobs in a workflow](https://docs.github.com/en/actions/managing-workflow-runs/re-running-workflows-and-jobs?tool=webui#re-running-failed-jobs-in-a-workflow) is not suited for use with parallel recording into Cypress Cloud. Re-running failed jobs in this situation does not simply re-run failed Cypress tests. Instead it re-runs **all** Cypress tests, load-balanced over the containers with failed jobs.
818
+
819
+ To optimize runs when there are failing tests present, refer to optional [Cypress Cloud Smart Orchestration](https://docs.cypress.io/cloud/features/smart-orchestration/overview/) Premium features:
820
+
821
+ - [Spec Prioritization](https://docs.cypress.io/cloud/features/smart-orchestration/spec-prioritization)
822
+ - [Auto Cancellation](https://docs.cypress.io/guides/cloud/smart-orchestration/run-cancellation). See also [Auto cancel after failures](#auto-cancel-after-failures) for details of how to set this option in a Cypress GitHub Action workflow.
823
+
824
+ During staged rollout of a new [GitHub-hosted runner image](https://github.com/actions/runner-images#readme) version,
825
+ GitHub may provide a mixture of current and new image versions used by the job matrix.
826
+ When running parallel jobs under GitHub-hosted Ubuntu runner images,
827
+ it is recommended to use a [Docker image](#docker-image)
828
+ to avoid any Cypress Cloud errors due to browser major version mismatch between the current and new image versions.
829
+
830
+ Avoid using parallel jobs with GitHub-hosted macOS or Windows runner images,
831
+ since there is currently no workaround for the deployment mismatch issue.
832
+ On macOS the problem can also occur when there is an upgrade to the macOS version.
833
+
834
+ [![recording example](https://github.com/cypress-io/github-action/actions/workflows/example-recording.yml/badge.svg)](.github/workflows/example-recording.yml)
835
+
836
+ ### Component and E2E Testing
837
+
838
+ [Component Testing](https://on.cypress.io/app/core-concepts/testing-types#What-is-Component-Testing) and [End-to-End (E2E) Testing](https://on.cypress.io/app/core-concepts/testing-types#What-is-E2E-Testing) types can be combined in the same job using separate steps
839
+
840
+ ```yml
841
+ - name: Run E2E tests
842
+ uses: cypress-io/github-action@v7
843
+
844
+ - name: Run Component Testing
845
+ uses: cypress-io/github-action@v7
846
+ with:
847
+ # we have already installed everything
848
+ install: false
849
+ component: true
850
+ ```
851
+
852
+ See the example project [component-test](examples/component-tests/) and the [example-component-test.yml](.github/workflows/example-component-test.yml) workflow for more details.
853
+
854
+ ### Build app
855
+
856
+ You can run a build step before starting tests
857
+
858
+ ```yml
859
+ name: Build
860
+ on: push
861
+ jobs:
862
+ cypress-run:
863
+ runs-on: ubuntu-26.04
864
+ steps:
865
+ - name: Checkout
866
+ uses: actions/checkout@v7
867
+ - name: Cypress run
868
+ uses: cypress-io/github-action@v7
869
+ with:
870
+ build: npm run build
871
+ ```
872
+
873
+ ### Start server
874
+
875
+ If your tests run against a local server, use the `start` parameter to start your server. The server will run in the background.
876
+
877
+ ```yml
878
+ name: With server
879
+ on: push
880
+ jobs:
881
+ cypress-run:
882
+ runs-on: ubuntu-26.04
883
+ steps:
884
+ - name: Checkout
885
+ uses: actions/checkout@v7
886
+ - name: Cypress run
887
+ uses: cypress-io/github-action@v7
888
+ with:
889
+ start: npm start
890
+ ```
891
+
892
+ **Caution:** use the `start` parameter only to start a server, not to run Cypress, otherwise tests may be run twice. The action runs Cypress tests by default, unless the parameter `runTests` is set to `false`.
893
+
894
+ **Note:** sometimes on Windows you need to run a different start command. You can use the `start-windows` parameter for this.
895
+
896
+ ```yml
897
+ name: With server
898
+ on: push
899
+ jobs:
900
+ cypress-run:
901
+ runs-on: ubuntu-26.04
902
+ steps:
903
+ - name: Checkout
904
+ uses: actions/checkout@v7
905
+ - name: Cypress run
906
+ uses: cypress-io/github-action@v7
907
+ with:
908
+ # Linux and macOS
909
+ start: npm start
910
+ # Takes precedences on Windows
911
+ start-windows: npm run start:windows:server
912
+ ```
913
+
914
+ [![start example](https://github.com/cypress-io/github-action/actions/workflows/example-start.yml/badge.svg)](.github/workflows/example-start.yml)
915
+
916
+ **Note:** A server continues to run until the end of the GitHub workflow job that started it. At the end of the job the GitHub workflow runner executes a "Complete job" phase automatically where it terminates any server processes which are still running.
917
+
918
+ ### Start multiple servers
919
+
920
+ You can start multiple server processes. For example, if you have an API to start using `npm run api` and the web server to start using `npm run web` you can put those commands in `start` using comma separation.
921
+
922
+ ```yml
923
+ name: With servers
924
+ on: push
925
+ jobs:
926
+ cypress-run:
927
+ runs-on: ubuntu-26.04
928
+ steps:
929
+ - name: Checkout
930
+ uses: actions/checkout@v7
931
+ - name: Cypress run
932
+ uses: cypress-io/github-action@v7
933
+ with:
934
+ start: npm run api, npm run web
935
+ ```
936
+
937
+ You can place the start commands in separate lines
938
+
939
+ ```yml
940
+ with:
941
+ start: |
942
+ npm run api
943
+ npm run web
944
+ ```
945
+
946
+ [![start example](https://github.com/cypress-io/github-action/actions/workflows/example-start.yml/badge.svg)](.github/workflows/example-start.yml)
947
+
948
+ ### Wait-on
949
+
950
+ If you are starting a local server and it takes a while to start, you can add a parameter `wait-on` and pass url to wait for the server to respond.
951
+
952
+ ```yml
953
+ name: After server responds
954
+ on: push
955
+ jobs:
956
+ cypress-run:
957
+ runs-on: ubuntu-26.04
958
+ steps:
959
+ - name: Checkout
960
+ uses: actions/checkout@v7
961
+ - name: Cypress run
962
+ uses: cypress-io/github-action@v7
963
+ with:
964
+ start: npm start
965
+ # quote the url to be safe against YML parsing surprises
966
+ wait-on: 'http://localhost:8080'
967
+ ```
968
+
969
+ [![wait-on example](https://github.com/cypress-io/github-action/actions/workflows/example-wait-on.yml/badge.svg)](.github/workflows/example-wait-on.yml)
970
+
971
+ [![Webpack Dev Server example](https://github.com/cypress-io/github-action/actions/workflows/example-webpack.yml/badge.svg)](.github/workflows/example-webpack.yml) (also uses `wait-on`)
972
+
973
+ By default, `wait-on` will retry for 60 seconds. You can pass a custom timeout in seconds using `wait-on-timeout`.
974
+
975
+ ```yml
976
+ - uses: cypress-io/github-action@v7
977
+ with:
978
+ start: npm start
979
+ wait-on: 'http://localhost:8080/status'
980
+ # wait for 2 minutes for the server to respond
981
+ wait-on-timeout: 120
982
+ ```
983
+
984
+ You can wait for multiple URLs to respond by separating urls with a comma
985
+
986
+ ```yml
987
+ - uses: cypress-io/github-action@v7
988
+ with:
989
+ # API runs on port 3050
990
+ # Web server runs on port 8080
991
+ start: npm run api, npm run web
992
+ # wait for all services to respond
993
+ wait-on: 'http://localhost:3050, http://localhost:8080'
994
+ ```
995
+
996
+ The action will wait for the first url to respond, then will check the second url, and so on.
997
+
998
+ You can even use your own command (usually by using `npm`, `yarn`, `npx`) to wait for the server to respond. For example, if you want to use the [wait-on](https://github.com/jeffbski/wait-on) utility to ping the server and run the Cypress tests after the server responds:
999
+
1000
+ ```yml
1001
+ - uses: cypress-io/github-action@v7
1002
+ with:
1003
+ start: npm start
1004
+ wait-on: 'npx wait-on --timeout 60000 http://localhost:3000'
1005
+ ```
1006
+
1007
+ See [example-wait-on.yml](.github/workflows/example-wait-on.yml) workflow file.
1008
+
1009
+ If this action times out waiting for the server to respond, please see [Debugging](#debugging) section in this README file.
1010
+
1011
+ ### Custom install command
1012
+
1013
+ The action installs dependencies based on a package manager lock file using default commands described in the [Installation](#installation) section below. If you want to overwrite the default install command you can use the `install-command` option:
1014
+
1015
+ ```yml
1016
+ - uses: cypress-io/github-action@v7
1017
+ with:
1018
+ install-command: yarn --frozen-lockfile --silent
1019
+ ```
1020
+
1021
+ See [example-install-command.yml](.github/workflows/example-install-command.yml) workflow file.
1022
+
1023
+ If you do not commit a lock file to the repository, you cannot use the action to install dependencies. In this case you must ensure that dependencies are installed before using the action, and you must use the action option setting `install: false`.
1024
+
1025
+ ### Command prefix
1026
+
1027
+ You can prefix a test command using the `command-prefix` parameter. This is useful, for example, when running [BrowserStack Percy](https://www.browserstack.com/docs/percy/integrate/cypress), which requires the test command to be prefixed with `percy exec --`. When this parameter is used, the action constructs and executes a CLI command using [npx](https://docs.npmjs.com/cli/v11/commands/npx) in the following form:
1028
+
1029
+ ```shell
1030
+ npx <command-prefix> cypress run <cli run options>
1031
+ ```
1032
+
1033
+ where the `<command-prefix>` is the literal string value from the `command-prefix` parameter and `<cli run options>` are put together from action parameters such as the value of the `browser` parameter. The complete constructed command is shown in the logs. For the example below, this is shown as:
1034
+
1035
+ ```text
1036
+ Cypress test command: npx percy exec -- npx cypress run --browser chrome
1037
+ ```
1038
+
1039
+ Since `command-prefix` is run using `npx`, it is compatible with [npm](https://docs.npmjs.com/cli/v11/) and [Yarn Classic](https://classic.yarnpkg.com/). It may also be used with [pnpm](https://pnpm.io/settings#nodelinker) and [Yarn Modern](https://yarnpkg.com/configuration/yarnrc#nodeLinker) when they are configured for `nodeLinker` compatibility with the `node_modules` directory structure of npm. An alternative to using `command-prefix` is to pass a complete [command](#custom-test-command) parameter instead, including the exact command to be passed to the CLI.
1040
+
1041
+ ```yml
1042
+ name: Visual
1043
+ on: push
1044
+ jobs:
1045
+ e2e:
1046
+ runs-on: ubuntu-26.04
1047
+ steps:
1048
+ - name: Checkout
1049
+ uses: actions/checkout@v7
1050
+ - name: Cypress run
1051
+ uses: cypress-io/github-action@v7
1052
+ with:
1053
+ command-prefix: 'percy exec -- npx'
1054
+ browser: chrome
1055
+ ```
1056
+
1057
+ If `command-prefix` is used, then no [job summary](#job-summary-title) is produced, since it runs Cypress with a CLI [cypress run](https://on.cypress.io/app/references/command-line#cypress-run) command instead of using the [Cypress Module API](https://docs.cypress.io/app/references/module-api). The `command` parameter overrides the `command-prefix` parameter, preventing these two parameters from being used together.
1058
+
1059
+ ### Custom test command
1060
+
1061
+ The `command` parameter executes a CLI command using the GitHub [@actions/exec](https://github.com/actions/toolkit/tree/main/packages/exec) action.
1062
+
1063
+ This parameter is useful for special test cases, for example:
1064
+
1065
+ - in the project [examples/custom-command](./examples/custom-command/), a JavaScript [examples/custom-command/index.js](./examples/custom-command/index.js) is run with `node .` through `command: npm run custom-test`
1066
+ - in the workflow [example-yarn-modern-pnp.yml](.github/workflows/example-yarn-modern-pnp.yml) Yarn Modern with Plug'n'Play is run with `command: yarn run --binaries-only cypress run` since [Yarn Plug'n'Play](#yarn-plugnplay) is not natively supported by the action.
1067
+
1068
+ If you don't have a special case and you just need to convert a `cypress run` CLI command to use the Cypress GitHub Action, refer to the section [Migrating from CLI command](#migrating-from-cli-command) which explains how to map CLI options to equivalent action parameters, avoiding the need for the `command` parameter in most cases.
1069
+
1070
+ There are some parameters that cannot be used together with the `command` parameter, and these are ignored. The parameters include action input parameters listed in the table [CLI Run Option / Action Parameter](#cli-run-option--action-parameter), the [publish-summary](#suppress-job-summary), [summary-title](#job-summary-title) and [command-prefix](#command-prefix). If any such parameters are passed to the action, a warning message appears in the logs that the parameters have been ignored.
1071
+
1072
+ Correct example snippet:
1073
+
1074
+ ```yml
1075
+ steps:
1076
+ - uses: actions/checkout@v7
1077
+ - uses: cypress-io/github-action@v7
1078
+ with:
1079
+ command: npm run custom-test
1080
+ ```
1081
+
1082
+ [![command example](https://github.com/cypress-io/github-action/actions/workflows/example-custom-command.yml/badge.svg)](.github/workflows/example-custom-command.yml)
1083
+
1084
+ ### Custom build id
1085
+
1086
+ You can overwrite [`ci-build-id`](https://on.cypress.io/parallelization#Linking-CI-machines-for-parallelization-or-grouping) used to link separate machines running tests into a single parallel run.
1087
+
1088
+ ```yml
1089
+ name: Parallel
1090
+ on: push
1091
+ jobs:
1092
+ test:
1093
+ runs-on: ubuntu-26.04
1094
+ strategy:
1095
+ matrix:
1096
+ # run 3 copies of the current job in parallel
1097
+ recording-job: [1, 2, 3]
1098
+ container:
1099
+ image: cypress/browsers:latest
1100
+ options: --user 1001
1101
+ steps:
1102
+ - uses: actions/checkout@v7
1103
+ - uses: cypress-io/github-action@v7
1104
+ with:
1105
+ record: true
1106
+ parallel: true
1107
+ group: 'Actions example'
1108
+ ci-build-id: '${{ github.sha }}-${{ github.workflow }}-${{ github.event_name }}'
1109
+ env:
1110
+ # pass the Cypress Cloud record key as an environment variable
1111
+ CYPRESS_RECORD_KEY: ${{ secrets.EXAMPLE_RECORDING_KEY }}
1112
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1113
+ ```
1114
+
1115
+ **Tip:** see [Learn GitHub Actions](https://docs.github.com/en/actions/learn-github-actions), with sections on Expressions, Contexts and Environment variables.
1116
+
1117
+ ### Robust custom build id
1118
+
1119
+ If you re-run the GitHub workflow, if you use the same custom build id during recording, Cypress Cloud will cancel the run with "Build already finished" error. To avoid this, you need to generate a _new_ custom build id on every workflow re-run. A good solution showing in the [example-custom-ci-build-id.yml](.github/workflows/example-custom-ci-build-id.yml) file is to run a common job first that just generates a new random ID. This ID can be used by the testing jobs to tie the build together. If the user re-runs the workflow a new unique build id is generated, allowing recording the new Cypress Cloud run.
1120
+
1121
+ ```yml
1122
+ jobs:
1123
+ # single job that generates and outputs a common id
1124
+ prepare:
1125
+ outputs:
1126
+ uuid: ${{ steps.uuid.outputs.value }}
1127
+ steps:
1128
+ - name: Generate unique ID 💎
1129
+ id: uuid
1130
+ # take the current commit + timestamp together
1131
+ # the typical value would be something like
1132
+ # "sha-5d3fe...35d3-time-1620841214"
1133
+ run: echo "value=sha-$GITHUB_SHA-time-$(date +"%s")" >> $GITHUB_OUTPUT
1134
+ smoke-tests:
1135
+ needs: ['prepare']
1136
+ container:
1137
+ image: cypress/browsers:latest
1138
+ options: --user 1001
1139
+ steps:
1140
+ - uses: actions/checkout@v7
1141
+ - uses: cypress-io/github-action@v7
1142
+ with:
1143
+ record: true
1144
+ parallel: true
1145
+ ci-build-id: ${{ needs.prepare.outputs.uuid }}
1146
+ env:
1147
+ # pass the Cypress Cloud record key as an environment variable
1148
+ CYPRESS_RECORD_KEY: ${{ secrets.EXAMPLE_RECORDING_KEY }}
1149
+ ```
1150
+
1151
+ See the [example-custom-ci-build-id.yml](.github/workflows/example-custom-ci-build-id.yml) for the full workflow.
1152
+
1153
+ ### Working directory
1154
+
1155
+ In a monorepo, the end-to-end or component test might be placed in a different sub-folder from the application itself. This sub-folder is the Cypress "working directory" which you can specify using the `working-directory` parameter.
1156
+
1157
+ In the following example of a directory layout for end-to-end testing, the Cypress working directory is `app-test`. The working directory contains the Cypress tests and a package manager lock file:
1158
+
1159
+ ```text
1160
+ repo/
1161
+ app/
1162
+ app-test/
1163
+ cypress/
1164
+ e2e/
1165
+ fixtures/
1166
+ support/
1167
+ cypress.config.js
1168
+ package.json
1169
+ package-lock.json
1170
+ ```
1171
+
1172
+ We use `working-directory: app-test` to match the above example directory structure:
1173
+
1174
+ ```yml
1175
+ on: push
1176
+ jobs:
1177
+ cypress-run:
1178
+ runs-on: ubuntu-26.04
1179
+ steps:
1180
+ - uses: actions/checkout@v7
1181
+ - uses: cypress-io/github-action@v7
1182
+ with:
1183
+ start: npm start
1184
+ working-directory: app-test
1185
+ ```
1186
+
1187
+ See the Cypress documentation [Folder structure](https://on.cypress.io/guides/core-concepts/writing-and-organizing-tests#Folder-Structure) section for examples of standard directory layouts, covering end-to-end testing and component testing with both JavaScript and TypeScript options.
1188
+
1189
+ Each of the examples in this monorepo is separated from other examples by using different working directories. See [example-basic.yml](.github/workflows/example-basic.yml) for one end-to-end test example using the parameter `working-directory` and [example-component-test.yml](.github/workflows/example-component-test.yml) for a component test example.
1190
+
1191
+ ### Subfolders
1192
+
1193
+ Sometimes the application under test and the Cypress end-to-end tests may have separately defined dependencies. In the example below, Cypress has its own `package.json` file in a subfolder:
1194
+
1195
+ ```text
1196
+ root/
1197
+ e2e/
1198
+ (code for installing and running Cypress tests)
1199
+ package.json
1200
+ package-lock.json
1201
+ cypress.config.js
1202
+ cypress/
1203
+
1204
+ (code for running the "app" with "npm start")
1205
+ package.json
1206
+ package-lock.json
1207
+ ```
1208
+
1209
+ In this case you can first install the dependencies for the application (`npm ci`), then start the application server (`npm start`) before calling `cypress-io/github-action` to install the dependencies for Cypress and to run Cypress. You may also need to use the [wait-on](#wait-on) parameter to make sure that the app server is fully available.
1210
+
1211
+ ```yml
1212
+ name: E2E
1213
+ on: push
1214
+ jobs:
1215
+ test:
1216
+ runs-on: ubuntu-26.04
1217
+ steps:
1218
+ - uses: actions/checkout@v7
1219
+ - name: Install root dependencies
1220
+ run: npm ci
1221
+
1222
+ - name: Start server in the background
1223
+ run: npm start &
1224
+
1225
+ # Cypress has its own package.json in folder "e2e"
1226
+ - name: Install Cypress and run tests
1227
+ uses: cypress-io/github-action@v7
1228
+ with:
1229
+ working-directory: e2e
1230
+ ```
1231
+
1232
+ ### pnpm
1233
+
1234
+ The package manager `pnpm` is not pre-installed in [GitHub Actions runner images](https://github.com/actions/runner-images)
1235
+ (unlike npm and Yarn Classic) and so it must be installed in a separate workflow step (see below).
1236
+ If the action finds a `pnpm-lock.yaml` file, it uses the [pnpm](https://pnpm.io/cli/install) command `pnpm install --frozen-lockfile` by default to install dependencies.
1237
+
1238
+ The example below follows [pnpm recommendations](https://pnpm.io/continuous-integration#github-actions) for installing pnpm and caching the
1239
+ [pnpm store](https://pnpm.io/cli/store).
1240
+ Follow the [Cypress pnpm configuration instructions](https://docs.cypress.io/app/get-started/install-cypress#pnpm-configuration)
1241
+ and apply them to your project, to enable pnpm to install the Cypress binary.
1242
+
1243
+ ```yaml
1244
+ name: example-basic-pnpm
1245
+ on: push
1246
+ jobs:
1247
+ basic-pnpm:
1248
+ runs-on: ubuntu-26.04
1249
+ steps:
1250
+ - name: Checkout
1251
+ uses: actions/checkout@v7
1252
+ - name: Install pnpm
1253
+ uses: pnpm/action-setup@v6
1254
+ with:
1255
+ version: 12
1256
+ - name: Install Node.js
1257
+ uses: actions/setup-node@v7
1258
+ with:
1259
+ node-version: 24
1260
+ cache: 'pnpm'
1261
+ cache-dependency-path: examples/basic-pnpm/pnpm-lock.yaml
1262
+ - name: Cypress run
1263
+ uses: cypress-io/github-action@v7
1264
+ with:
1265
+ package-manager-cache: false
1266
+ working-directory: examples/basic-pnpm
1267
+ ```
1268
+
1269
+ [![pnpm example](https://github.com/cypress-io/github-action/actions/workflows/example-basic-pnpm.yml/badge.svg)](.github/workflows/example-basic-pnpm.yml)
1270
+
1271
+ ### pnpm workspaces
1272
+
1273
+ The action does not directly support using [pnpm workspaces](https://pnpm.io/workspaces)
1274
+ (see feature request [#1144](https://github.com/cypress-io/github-action/issues/1144)).
1275
+ As a workaround, you can install dependencies and run Cypress tests in a workspace in separate steps.
1276
+ The snippet below shows this principle.
1277
+
1278
+ ```yml
1279
+ ...
1280
+ - name: Install dependencies
1281
+ uses: cypress-io/github-action@v7
1282
+ with:
1283
+ package-manager-cache: false
1284
+ runTests: false
1285
+ working-directory: examples/start-and-pnpm-workspaces
1286
+
1287
+ - name: Cypress test
1288
+ uses: cypress-io/github-action@v7
1289
+ with:
1290
+ install: false
1291
+ working-directory: examples/start-and-pnpm-workspaces/packages/workspace-1
1292
+ ...
1293
+ ```
1294
+
1295
+ [![pnpm workspaces example](https://github.com/cypress-io/github-action/actions/workflows/example-start-and-pnpm-workspaces.yml/badge.svg)](.github/workflows/example-start-and-pnpm-workspaces.yml)
1296
+
1297
+ See the example project [start-and-pnpm-workspaces](examples/start-and-pnpm-workspaces/) and the [example-start-and-pnpm-workspaces.yml](.github/workflows/example-start-and-pnpm-workspaces.yml) workflow for a full working example.
1298
+
1299
+ ### Yarn Classic
1300
+
1301
+ If a `yarn.lock` file is found, the action uses the [Yarn 1 (Classic)](https://classic.yarnpkg.com/) command `yarn --frozen-lockfile` by default to install dependencies.
1302
+
1303
+ ```yaml
1304
+ name: example-yarn-classic
1305
+ on: push
1306
+ jobs:
1307
+ yarn-classic:
1308
+ runs-on: ubuntu-26.04
1309
+ steps:
1310
+ - name: Checkout
1311
+ uses: actions/checkout@v7
1312
+ - name: Cypress run
1313
+ uses: cypress-io/github-action@v7
1314
+ with:
1315
+ working-directory: examples/yarn-classic
1316
+ ```
1317
+
1318
+ [![Yarn classic example](https://github.com/cypress-io/github-action/actions/workflows/example-yarn-classic.yml/badge.svg)](.github/workflows/example-yarn-classic.yml)
1319
+
1320
+ ### Yarn Modern
1321
+
1322
+ To install dependencies using a `yarn.lock` file from [Yarn Modern](https://yarnpkg.com/) (Yarn 2 and later) you need to override the default [Yarn 1 (Classic)](https://classic.yarnpkg.com/) installation command `yarn --frozen-lockfile`. You can do this by using the `install-command` parameter and specifying `yarn install` as in the example below.
1323
+
1324
+ The action supports built-in caching of Yarn Classic dependencies only. To cache Yarn Modern dependencies additionally use [actions/setup-node](https://github.com/actions/setup-node) and specify `cache: yarn`.
1325
+
1326
+ ```yaml
1327
+ name: example-yarn-modern
1328
+ on: push
1329
+ jobs:
1330
+ yarn-modern:
1331
+ runs-on: ubuntu-26.04
1332
+ steps:
1333
+ - name: Checkout
1334
+ uses: actions/checkout@v7
1335
+ - run: corepack enable # (experimental and optional)
1336
+ - name: Set up Yarn cache
1337
+ uses: actions/setup-node@v7
1338
+ with:
1339
+ node-version: 24
1340
+ cache: yarn
1341
+ cache-dependency-path: examples/yarn-modern/yarn.lock
1342
+ - name: Cypress run
1343
+ uses: cypress-io/github-action@v7
1344
+ with:
1345
+ working-directory: examples/yarn-modern
1346
+ install-command: yarn install
1347
+ ```
1348
+
1349
+ This example covers the [`.yarnrc.yml`](https://yarnpkg.com/configuration/yarnrc#nodeLinker) configuration `nodeLinker: node-modules` which Yarn uses by default for projects updated from Yarn Classic. For `nodeLinker: pnp` see [Yarn Plug'n'Play](#yarn-plugnplay) below.
1350
+ (Note that `github-action` is not compatible with the `nodeLinker: pnpm` setting.)
1351
+
1352
+ [![Yarn Modern example](https://github.com/cypress-io/github-action/actions/workflows/example-yarn-modern.yml/badge.svg)](.github/workflows/example-yarn-modern.yml)
1353
+
1354
+ ### Yarn Plug'n'Play
1355
+
1356
+ When using [Yarn Modern](https://yarnpkg.com/) (Yarn 2 and later) with [Plug'n'Play](https://yarnpkg.com/features/pnp) enabled, you will need to use the `command` parameter to run [`yarn`](https://yarnpkg.com/cli/run) instead of [`npx`](https://docs.npmjs.com/cli/v9/commands/npx).
1357
+
1358
+ See the above [Yarn Modern](#yarn-modern) section for information on caching Yarn Modern dependencies.
1359
+
1360
+ ```yaml
1361
+ name: example-yarn-modern-pnp
1362
+ on: push
1363
+ jobs:
1364
+ yarn-classic:
1365
+ runs-on: ubuntu-26.04
1366
+ steps:
1367
+ - name: Checkout
1368
+ uses: actions/checkout@v7
1369
+ - name: Cypress run
1370
+ uses: cypress-io/github-action@v7
1371
+ with:
1372
+ working-directory: examples/yarn-modern-pnp
1373
+ install-command: yarn install
1374
+ command: yarn run --binaries-only cypress run
1375
+ ```
1376
+
1377
+ This example covers the [`.yarnrc.yml`](https://yarnpkg.com/configuration/yarnrc#nodeLinker) configuration when `nodeLinker` is undefined or set to `nodeLinker: pnp` corresponding to Yarn Plug'n'Play. Yarn uses this by default for projects newly created with Yarn Modern.
1378
+
1379
+ [![Yarn Plug'n'Play example](https://github.com/cypress-io/github-action/actions/workflows/example-yarn-modern-pnp.yml/badge.svg)](https://github.com/cypress-io/github-action/actions/workflows/example-yarn-modern-pnp.yml)
1380
+
1381
+ **Caution**: using the action parameter `command` causes multiple other parameters to be ignored. [See `command` section for more information.](#custom-test-command)
1382
+
1383
+ ### Yarn workspaces
1384
+
1385
+ This action should discover the Yarn workspaces correctly. For example, see folder [examples/start-and-yarn-workspaces](examples/start-and-yarn-workspaces) and workflow file [example-start-and-yarn-workspaces.yml](.github/workflows/example-start-and-yarn-workspaces.yml)
1386
+
1387
+ ```yaml
1388
+ name: example-start-and-yarn-workspaces
1389
+ on: push
1390
+ jobs:
1391
+ single:
1392
+ # the example has Yarn workspace in its "root" folder
1393
+ # examples/start-and-yarn-workspaces
1394
+ # and tests in a subfolder like "workspace-1"
1395
+ runs-on: ubuntu-26.04
1396
+ steps:
1397
+ - uses: actions/checkout@v7
1398
+ - uses: cypress-io/github-action@v7
1399
+ with:
1400
+ working-directory: examples/start-and-yarn-workspaces/workspace-1
1401
+ build: yarn run build
1402
+ start: yarn start
1403
+ wait-on: 'http://localhost:5000'
1404
+ ```
1405
+
1406
+ [![Yarn workspaces example](https://github.com/cypress-io/github-action/actions/workflows/example-start-and-yarn-workspaces.yml/badge.svg)](.github/workflows/example-start-and-yarn-workspaces.yml)
1407
+
1408
+ ### Package manager cache disable
1409
+
1410
+ When the action installs dependencies,
1411
+ it caches the package manager cache from npm or from Yarn 1 (Classic) by default,
1412
+ based on the [lockfile](#package-manager-cache) it discovers.
1413
+ If package manager caching is implemented separately from the action,
1414
+ for example to work with Yarn Modern or pnpm,
1415
+ then disable the actions' package manager caching by setting the parameter
1416
+ `package-manager-cache` to `false`.
1417
+
1418
+ GitHub's [actions/setup-node](https://github.com/actions/setup-node/blob/main/README.md) offers a convenient way to install a chosen version of Node.js
1419
+ and to set up caching of package manager caches in one step.
1420
+
1421
+ ```yml
1422
+ name: Package manager caching
1423
+ on: push
1424
+ jobs:
1425
+ cypress-run:
1426
+ runs-on: ubuntu-26.04
1427
+ name:
1428
+ steps:
1429
+ - uses: actions/checkout@v7
1430
+ - uses: actions/setup-node@v7
1431
+ with:
1432
+ node-version: lts
1433
+ cache: 'pnpm'
1434
+ cache-dependency-path: pnpm-lock.yaml
1435
+ - uses: cypress-io/github-action@v7
1436
+ with:
1437
+ package-manager-cache: false
1438
+ ```
1439
+
1440
+ ### Custom cache key
1441
+
1442
+ Sometimes the default cache key does not work. For example, if you cannot share the Node modules across Node versions due to native extensions. In that case pass your own `cache-key` parameter.
1443
+
1444
+ ```yml
1445
+ name: End-to-end tests
1446
+ on: push
1447
+ jobs:
1448
+ cypress-run:
1449
+ runs-on: ubuntu-26.04
1450
+ # let's make sure our "app" works on several versions of Node
1451
+ strategy:
1452
+ matrix:
1453
+ node:
1454
+ - 22
1455
+ - 24
1456
+ - 26
1457
+ name: E2E on Node v${{ matrix.node }}
1458
+ steps:
1459
+ - name: Checkout
1460
+ uses: actions/checkout@v7
1461
+ - name: Install Node.js
1462
+ uses: actions/setup-node@v7
1463
+ with:
1464
+ node-version: ${{ matrix.node }}
1465
+ # run Cypress tests and record them under the same run
1466
+ # associated with commit SHA and just give a different group name
1467
+ - name: Cypress run
1468
+ uses: cypress-io/github-action@v7
1469
+ with:
1470
+ record: true
1471
+ group: Tests on Node v${{ matrix.node }}
1472
+ cache-key: node-v${{ matrix.node }}-on-${{ runner.os }}-hash-${{ hashFiles('yarn.lock') }}
1473
+ env:
1474
+ CYPRESS_RECORD_KEY: ${{ secrets.EXAMPLE_RECORDING_KEY }}
1475
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1476
+ ```
1477
+
1478
+ ### Node versions
1479
+
1480
+ You can run your tests across multiple Node versions.
1481
+
1482
+ ```yml
1483
+ name: Node versions
1484
+ on: push
1485
+ jobs:
1486
+ cypress-run:
1487
+ runs-on: ubuntu-26.04
1488
+ strategy:
1489
+ matrix:
1490
+ node:
1491
+ - 22
1492
+ - 24
1493
+ - 26
1494
+ name: E2E on Node v${{ matrix.node }}
1495
+ steps:
1496
+ - uses: actions/checkout@v7
1497
+ - uses: actions/setup-node@v7
1498
+ with:
1499
+ node-version: ${{ matrix.node }}
1500
+ - uses: cypress-io/github-action@v7
1501
+ ```
1502
+
1503
+ See the [Node.js](#nodejs) section for information about supported versions and usage of Node.js.
1504
+
1505
+ [![Node versions example](https://github.com/cypress-io/github-action/actions/workflows/example-node-versions.yml/badge.svg)](.github/workflows/example-node-versions.yml)
1506
+
1507
+ ### Split install and tests
1508
+
1509
+ Sometimes you may want to run additional commands between installation and tests. To enable this use the `install` and `runTests` parameters.
1510
+
1511
+ ```yml
1512
+ name: E2E
1513
+ on: push
1514
+ jobs:
1515
+ test:
1516
+ runs-on: ubuntu-26.04
1517
+ steps:
1518
+ - uses: actions/checkout@v7
1519
+ - name: Install dependencies
1520
+ uses: cypress-io/github-action@v7
1521
+ with:
1522
+ # just perform install
1523
+ runTests: false
1524
+ - run: yarn lint
1525
+ - name: Run e2e tests
1526
+ uses: cypress-io/github-action@v7
1527
+ with:
1528
+ # we have already installed all dependencies above
1529
+ install: false
1530
+ # Cypress tests and config file are in "e2e" folder
1531
+ working-directory: e2e
1532
+ ```
1533
+
1534
+ See [cypress-gh-action-monorepo](https://github.com/bahmutov/cypress-gh-action-monorepo) for a working example.
1535
+
1536
+ ### Split install and test with artifacts
1537
+
1538
+ If your test job(s) first need a build step, you can split the jobs into a separate build job followed by test jobs. You pass the build results to any subsequent jobs using [GitHub Actions artifacts](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/storing-and-sharing-data-from-a-workflow).
1539
+
1540
+ In the build job, use [upload-artifact](https://github.com/actions/upload-artifact) to store the build results, then in subsequent jobs use [download-artifact](https://github.com/actions/download-artifact) to restore them.
1541
+
1542
+ Your tests jobs may use a [GitHub Actions matrix strategy](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/running-variations-of-jobs-in-a-workflow), such as when recording to [Cypress Cloud](https://on.cypress.io/cloud-introduction) with [parallel jobs](#parallel).
1543
+
1544
+ ```yml
1545
+ name: Split build and test
1546
+ on: push
1547
+ jobs:
1548
+ build:
1549
+ runs-on: ubuntu-26.04
1550
+ steps:
1551
+ - uses: actions/checkout@v7
1552
+ - name: Build app
1553
+ uses: cypress-io/github-action@v7
1554
+ with:
1555
+ runTests: false # only build app, don't test yet
1556
+ build: npm run build
1557
+ - name: Store build artifacts
1558
+ uses: actions/upload-artifact@v7
1559
+ with:
1560
+ name: app
1561
+ path: build
1562
+ if-no-files-found: error
1563
+ retention-days: 1
1564
+
1565
+ test:
1566
+ needs: build
1567
+ runs-on: ubuntu-26.04
1568
+ steps:
1569
+ - uses: actions/checkout@v7
1570
+ - name: Restore build artifacts
1571
+ uses: actions/download-artifact@v8
1572
+ with:
1573
+ name: app
1574
+ path: build
1575
+
1576
+ - name: Cypress tests
1577
+ uses: cypress-io/github-action@v7
1578
+ with:
1579
+ start: npm start # start server using the build artifacts
1580
+ ```
1581
+
1582
+ [![Split with build artifacts](https://github.com/cypress-io/github-action/actions/workflows/example-build-artifacts.yml/badge.svg)](.github/workflows/example-build-artifacts.yml)
1583
+
1584
+ ### Custom install
1585
+
1586
+ Finally, you might not need this GH Action at all. For example, if you want to split the npm dependencies installation from the Cypress binary installation, then it makes no sense to use this action. Instead you can install and cache Cypress yourself.
1587
+
1588
+ ### Timeouts
1589
+
1590
+ You can tell the CI to stop the job or the individual step if it runs for longer then a given time limit. This is a good practice to ensure the hanging process does not accidentally use up all your CI minutes.
1591
+
1592
+ ```yml
1593
+ jobs:
1594
+ cypress-run:
1595
+ runs-on: ubuntu-26.04
1596
+ # stop the job if it runs over 10 minutes
1597
+ # to prevent a hanging process from using all your CI minutes
1598
+ timeout-minutes: 10
1599
+ steps:
1600
+ - uses: actions/checkout@v7
1601
+ - uses: cypress-io/github-action@v7
1602
+ # you can specify individual step timeout too
1603
+ timeout-minutes: 5
1604
+ ```
1605
+
1606
+ ### More examples
1607
+
1608
+ | Name | Description |
1609
+ | --------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- |
1610
+ | [cypress-io/cypress-example-kitchensink](https://github.com/cypress-io/cypress-example-kitchensink) | Runs every API command in Cypress using various CI platforms including GitHub Actions |
1611
+ | [cypress-io/cypress-realworld-app](https://github.com/cypress-io/cypress-realworld-app) | A real-world example payment application. Uses GitHub Actions and CircleCI. |
1612
+
1613
+ ## Migration
1614
+
1615
+ ### Migrating from CLI command
1616
+
1617
+ To migrate from Cypress [CLI run command options](https://on.cypress.io/command-line#Options) to Cypress GitHub Action parameters, check the [CLI Run Option / Action Parameter](#cli-run-option--action-parameter) table below. In most cases, the name of the action parameter is the same as the long form of the `cypress run` CLI option.
1618
+
1619
+ Create a [GitHub Actions workflow](https://docs.github.com/en/actions/writing-workflows/quickstart) referring to [Workflow syntax for GitHub Actions](https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions). The action `cypress-io/github-action@v7` is invoked with the `uses` keyword. Cypress GitHub Action input parameters are specified under the [with](https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#jobsjob_idstepswith) keyword.
1620
+
1621
+ If you have previously been using a [CLI command](https://on.cypress.io/command-line#cypress-run) to run Cypress locally or in a CI environment, you will be familiar with testing commands like this:
1622
+
1623
+ ```shell
1624
+ npx cypress run --spec cypress/e2e/spec.cy.js --browser chrome
1625
+ ```
1626
+
1627
+ or you may be using a script defined in your project's `package.json` file, such as:
1628
+
1629
+ ```json
1630
+ "cy:e2e:chrome": "cypress run --spec cypress/e2e/spec.cy.js --browser chrome"
1631
+ ```
1632
+
1633
+ Here is the equivalent GitHub Actions example workflow. The action runs Cypress by passing the action parameters (`browser` and `spec`) programmatically to the [Cypress Module API](https://on.cypress.io/module-api) without using any CLI. The complete workflow also checks out the repo and installs dependencies before running Cypress.
1634
+
1635
+ ```yml
1636
+ name: CLI migration example
1637
+ on: push
1638
+ jobs:
1639
+ cypress-run:
1640
+ runs-on: ubuntu-26.04
1641
+ steps:
1642
+ - name: Check out repo
1643
+ uses: actions/checkout@v7
1644
+ - name: Cypress run # install dependencies and run Cypress E2E tests
1645
+ uses: cypress-io/github-action@v7 # replaces CLI cypress run
1646
+ with:
1647
+ browser: chrome # replaces CLI option --browser chrome
1648
+ spec: cypress/e2e/spec.cy.js # replaces CLI option --spec cypress/e2e/spec.cy.js
1649
+ ```
1650
+
1651
+ #### CLI Run Option / Action Parameter
1652
+
1653
+ | CLI Option `cypress run` | Action Parameter | Description |
1654
+ | ------------------------------ | ----------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- |
1655
+ | `--auto-cancel-after-failures` | [`auto-cancel-after-failures`](#auto-cancel-after-failures) | Set the failed test threshold for auto cancellation or disable auto cancellation for Cloud recording |
1656
+ | `--browser`, `-b` | [`browser`](#browser) | Select browser that Cypress runs in. A filesystem path to a browser can also be used. |
1657
+ | `--ci-build-id` | [`ci-build-id`](#custom-build-id) | Specify a unique identifier for a run to enable grouping or parallelization for Cloud recording |
1658
+ | `--component` | [`component`](#component-testing) | Run component tests |
1659
+ | `--config`, `-c` | [`config`](#config) | Specify configuration |
1660
+ | `--config-file`, `-C` | [`config-file`](#config-file) | Specify configuration file |
1661
+ | `--e2e` | [`component: false`](#component-testing) (default) | Run end to end tests |
1662
+ | `--env`, `-e` | [`env`](#env) | Specify environment variables |
1663
+ | `--expose`, `-x` | [`expose`](#expose) | Specify expose variables for non-sensitive, public config values |
1664
+ | `--group` | [`group`](#parallel) | Group recorded tests together under a single run for Cloud recording |
1665
+ | `--headed` | [`headed`](#headed) | Display the browser instead of running headlessly |
1666
+ | `--headless` | [`headed: false`](#headed) (default) | Hide the browser instead of running headed |
1667
+ | `--parallel` | [`parallel`](#parallel) | Run recorded specs in parallel across multiple machines for Cloud recording |
1668
+ | `--project`, `-P` | [`project`](#project) | Path to a specific project |
1669
+ | `--quiet`, `-q` | [`quiet`](#quiet-flag) | Reduce output to `stdout` |
1670
+ | `--record` | [`record`](#record-test-results-on-cypress-cloud) | Record the test run to Cypress Cloud |
1671
+ | `--spec`, `-s` | [`spec`](#specs) | Specify the spec files to run |
1672
+ | `--tag`, `-t` | [`tag`](#tag-recordings) | Identify a run with a tag or tags |
1673
+
1674
+ There is no equivalent action parameter for the CLI options `help`, `key`, `--no-exit`, `--no-runner-ui`, `port`, `reporter`, `reporter-options` or `runner-ui`. See the section [Record test results on Cypress Cloud](#record-test-results-on-cypress-cloud) for information on passing a Cypress Cloud record key to the action.
1675
+
1676
+ ## Notes
1677
+
1678
+ ### Installation
1679
+
1680
+ This action installs local dependencies using lock files. Ensure that exactly one type of lock file is used at the root of the repo or in each working-directory of a monorepo from the following supported package managers:
1681
+
1682
+ | Lock file | Package Manager | Installation command |
1683
+ | ------------------- | ------------------------------------------------------------------------------------------------ | -------------------------------- |
1684
+ | `package-lock.json` | [npm](https://docs.npmjs.com/cli/v9/commands/npm-ci) | `npm ci` |
1685
+ | `pnpm-lock.yaml` | [pnpm](https://pnpm.io/cli/install#--frozen-lockfile) | `pnpm install --frozen-lockfile` |
1686
+ | `yarn.lock` | [Yarn Classic](https://classic.yarnpkg.com/en/docs/cli/install#toc-yarn-install-frozen-lockfile) | `yarn --frozen-lockfile` |
1687
+
1688
+ See section [Yarn Modern](#yarn-modern) for information about using Yarn version 2 and later.
1689
+
1690
+ ### Caching
1691
+
1692
+ When the action installs dependencies, it also caches these where possible using GitHub Actions [@actions/cache](https://github.com/actions/toolkit/tree/main/packages/cache).
1693
+
1694
+ #### Cypress binary cache
1695
+
1696
+ The Cypress binary is saved to the `$HOME/.cache/Cypress` directory or to a location defined by the environment variable `CYPRESS_CACHE_FOLDER`. This location is then cached by GitHub Actions and carries the cache label `cypress-<platform-and-architecture>-hash`.
1697
+
1698
+ #### Package Manager cache
1699
+
1700
+ Based on the package manager lock file, the action caches the following package manager cache locations:
1701
+
1702
+ | Lock file | Package Manager | Cached location |
1703
+ | ------------------- | ------------------------------------------------------------------- | ------------------- |
1704
+ | `package-lock.json` | [npm](https://docs.npmjs.com/cli/commands/npm-cache) | `$HOME/.npm` |
1705
+ | `yarn.lock` | [Yarn Classic](https://classic.yarnpkg.com/lang/en/docs/cli/cache/) | `$HOME/.cache/yarn` |
1706
+
1707
+ The cache carries the label `npm-<platform-and-architecture>-hash`.
1708
+ In the cache label, `npm` refers to the npm public registry at https://registry.npmjs.org from which both the above package managers download npm modules by default.
1709
+
1710
+ Note that the Cypress GitHub action does not include any built-in caching for pnpm and Yarn Modern.
1711
+ GitHub Actions however provides [actions/setup-node](https://github.com/actions/setup-node) which includes functionality to optionally cache npm, Yarn and pnpm dependencies. This can be added to any GitHub Actions workflow if needed. Examples are shown above for [pnpm](#pnpm) and [Yarn Modern](#yarn-modern).
1712
+
1713
+ ## Debugging
1714
+
1715
+ This action uses the [debug](https://github.com/debug-js/debug#readme) module to output additional verbose logs. You can see these debug messages by setting the following environment variable:
1716
+
1717
+ ```yml
1718
+ DEBUG: @cypress/github-action
1719
+ ```
1720
+
1721
+ You can set the environment variable using GitHub UI interface, or in the workflow file:
1722
+
1723
+ ```yml
1724
+ - name: Cypress tests with debug logs
1725
+ uses: cypress-io/github-action@v7
1726
+ env:
1727
+ DEBUG: '@cypress/github-action'
1728
+ ```
1729
+
1730
+ See the [example-debug.yml](.github/workflows/example-debug.yml) workflow file.
1731
+
1732
+ To collect more verbose GitHub Action logs you can set a GitHub secret or variable `ACTIONS_STEP_DEBUG` to `true`. This is useful to see detailed caching steps. See [Enabling debug logging](https://docs.github.com/en/actions/monitoring-and-troubleshooting-workflows/enabling-debug-logging) from GitHub Actions documentation for more information.
1733
+
1734
+ ### Logs from the test runner
1735
+
1736
+ To see all [Cypress debug logs](https://on.cypress.io/troubleshooting#Print-DEBUG-logs), add the environment variable `DEBUG` to the workflow using the value `cypress:*`:
1737
+
1738
+ ```yml
1739
+ - name: Cypress tests with debug logs
1740
+ uses: cypress-io/github-action@v7
1741
+ env:
1742
+ DEBUG: 'cypress:*'
1743
+ ```
1744
+
1745
+ Replace the value `cypress:*` with specific [Cypress log sources](https://on.cypress.io/troubleshooting#Log-sources) to filter debug log output.
1746
+
1747
+ ### Debugging waiting for URL to respond
1748
+
1749
+ If you have a problem with `wait-on` not working, you can check the [src/ping.js](src/ping.js) logic from the local machine.
1750
+
1751
+ - clone this repository to the local machine
1752
+ - install dependencies with `npm install`
1753
+ - start your server
1754
+ - from another terminal call the `ping` yourself to validate the server is responding:
1755
+
1756
+ ```shell
1757
+ node src/ping-cli.js <url>
1758
+ ```
1759
+
1760
+ For example:
1761
+
1762
+ ```text
1763
+ $ node src/ping-cli.js https://example.cypress.io
1764
+ pinging url https://example.cypress.io for 30 seconds
1765
+ ```
1766
+
1767
+ You can also enable debug logs by setting the environment variable `DEBUG='@cypress/github-action'`, for example:
1768
+
1769
+ ```text
1770
+ $ DEBUG='@cypress/github-action' node src/ping-cli.js https://example.cypress.io
1771
+ pinging url https://example.cypress.io for 30 seconds
1772
+ @cypress/github-action total ping timeout 60000 +0ms
1773
+ @cypress/github-action individual ping timeout 30000ms +0ms
1774
+ @cypress/github-action retries limit 2 +0ms
1775
+ @cypress/github-action pinging https://example.cypress.io has finished ok after 185ms +185ms
1776
+ ```
1777
+
1778
+ ## Extras
1779
+
1780
+ ### Manual trigger
1781
+
1782
+ Each of the `example-*` workflows in the [.github/workflows](https://github.com/cypress-io/github-action/tree/master/.github/workflows) directory is configured to trigger on a `workflow_dispatch` event. This allows any of these workflows to be run manually.
1783
+
1784
+ [Fork](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/fork-a-repo) and [clone](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/fork-a-repo#cloning-your-forked-repository) this repository to try out the examples live in your own repository copy. Refer to the GitHub Actions documentation [Manually running a workflow](https://docs.github.com/en/actions/managing-workflow-runs-and-deployments/managing-workflow-runs/manually-running-a-workflow) which explains how to run a workflow from the Actions tab on GitHub. Workflows can also be run using the GitHub CLI or the REST API.
1785
+
1786
+ If you configure a `workflow_dispatch` event in your own workflows, you will be able to run them manually in the same way.
1787
+
1788
+ ### Outputs
1789
+
1790
+ This action sets a GitHub step output `resultsUrl` if the run was recorded on [Cypress Cloud](https://on.cypress.io/cloud-introduction) using the action parameter setting `record: true` (see [Record test results on Cypress Cloud](#record-test-results-on-cypress-cloud)). Note that if a custom test command with the [command](#custom-test-command) parameter or the [command-prefix](#command-prefix) parameter are used then no `resultsUrl` step output is saved.
1791
+
1792
+ This is an example of using the step output `resultsUrl`:
1793
+
1794
+ ```yml
1795
+ - name: Cypress tests
1796
+ uses: cypress-io/github-action@v7
1797
+ # let's give this action an ID so we can refer
1798
+ # to its output values later
1799
+ id: cypress
1800
+ with:
1801
+ record: true
1802
+ env:
1803
+ CYPRESS_RECORD_KEY: ${{ secrets.EXAMPLE_RECORDING_KEY }}
1804
+ - name: Print Cypress Cloud URL
1805
+ if: always()
1806
+ run: |
1807
+ echo Cypress finished with: ${{ steps.cypress.outcome }}
1808
+ echo See results at ${{ steps.cypress.outputs.resultsUrl }}
1809
+ ```
1810
+
1811
+ The GitHub step output `dashboardUrl` is deprecated. Cypress Dashboard is now [Cypress Cloud](https://on.cypress.io/cloud-introduction).
1812
+
1813
+ [![recording example](https://github.com/cypress-io/github-action/actions/workflows/example-recording.yml/badge.svg)](.github/workflows/example-recording.yml)
1814
+
1815
+ **Note:** every GitHub workflow step can have `outcome` and `conclusion` properties. See the GitHub [Contexts](https://docs.github.com/en/actions/learn-github-actions/contexts) documentation section [steps context](https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#steps-context). In particular, the `outcome` or `conclusion` value can be `success`, `failure`, `cancelled`, or `skipped` which you can use in any following steps.
1816
+
1817
+ ### Print Cypress info
1818
+
1819
+ Sometimes you might want to print Cypress and OS information, like the list of detected browsers. You can use the [`cypress info`](https://on.cypress.io/command-line#cypress-info) command for this.
1820
+
1821
+ If you are NOT using the `build` command in your project, you can run the `cypress info` command:
1822
+
1823
+ ```yml
1824
+ name: info
1825
+ on: push
1826
+ jobs:
1827
+ cypress-run:
1828
+ runs-on: ubuntu-26.04
1829
+ steps:
1830
+ - name: Checkout
1831
+ uses: actions/checkout@v7
1832
+ - name: Cypress run
1833
+ uses: cypress-io/github-action@v7
1834
+ with:
1835
+ build: npx cypress info
1836
+ ```
1837
+
1838
+ If you are already using the `build` parameter, you can split the [installation and the test steps](#split-install-and-tests) and insert the `cypress info` command in between:
1839
+
1840
+ ```yml
1841
+ name: info
1842
+ on: push
1843
+ jobs:
1844
+ cypress-run:
1845
+ runs-on: ubuntu-26.04
1846
+ steps:
1847
+ - name: Checkout
1848
+ uses: actions/checkout@v7
1849
+ - name: Cypress install
1850
+ uses: cypress-io/github-action@v7
1851
+ with:
1852
+ # just perform install
1853
+ runTests: false
1854
+ - name: Cypress info
1855
+ run: npx cypress info
1856
+ - name: Cypress run
1857
+ uses: cypress-io/github-action@v7
1858
+ with:
1859
+ # we have already installed all dependencies above
1860
+ install: false
1861
+ # rest of your parameters
1862
+ ```
1863
+
1864
+ ### Nightly tests
1865
+
1866
+ Sometimes you want to execute the workflow on a schedule. For example, to run Cypress tests nightly, you can schedule the workflow using `cron` syntax:
1867
+
1868
+ ```yml
1869
+ name: example-cron
1870
+ on:
1871
+ schedule:
1872
+ # runs tests every day at 4am
1873
+ - cron: '0 4 * * *'
1874
+ jobs:
1875
+ nightly:
1876
+ runs-on: ubuntu-26.04
1877
+ steps:
1878
+ - name: Checkout
1879
+ uses: actions/checkout@v7
1880
+ - name: Cypress nightly tests 🌃
1881
+ uses: cypress-io/github-action@v7
1882
+ ```
1883
+
1884
+ [![cron example](https://github.com/cypress-io/github-action/actions/workflows/example-cron.yml/badge.svg)](.github/workflows/example-cron.yml)
1885
+
1886
+ ### Job summary title
1887
+
1888
+ By default, the action produces a job summary in the GitHub Actions log for each workflow step where `github-action` is used. Each job summary shows a Passing / Failing status, the test counts for Passed, Failed, Pending & Skipped, followed by the Duration of the run. The job summaries are grouped by job.
1889
+
1890
+ To specify a title for a Job Summary, use the parameter `summary-title`. If no title is specified, then the default "Cypress Results" is used:
1891
+
1892
+ ```yml
1893
+ name: Summary titles
1894
+ on: push
1895
+ jobs:
1896
+ tests:
1897
+ runs-on: ubuntu-26.04
1898
+ steps:
1899
+ - uses: actions/checkout@v7
1900
+ - name: Cypress headless tests
1901
+ uses: cypress-io/github-action@v7
1902
+ with:
1903
+ summary-title: 'Headless'
1904
+ - name: Cypress headed tests
1905
+ uses: cypress-io/github-action@v7
1906
+ with:
1907
+ install: false
1908
+ headed: true
1909
+ summary-title: 'Headed'
1910
+ ```
1911
+
1912
+ The name of the GitHub Actions job is shown at the top of one or more job summaries from the same job. If multiple summaries belong to the same job, then giving them separate titles allows them to be uniquely identified.
1913
+
1914
+ See the [example-chrome.yml](.github/workflows/example-chrome.yml) workflow, with multiple calls to `cypress-io/github-action` in one job, making use of the `summary-title` parameter. View the [example-chrome.yml - actions log](https://github.com/cypress-io/github-action/actions/workflows/example-chrome.yml) for an example of the resulting job summaries.
1915
+
1916
+ ### Suppress job summary
1917
+
1918
+ The default job summary can be suppressed by using the parameter `publish-summary` and setting its value to `false`.
1919
+
1920
+ ```yml
1921
+ name: Example no summary
1922
+ on: push
1923
+ jobs:
1924
+ cypress-run:
1925
+ runs-on: ubuntu-26.04
1926
+ steps:
1927
+ - name: Checkout
1928
+ uses: actions/checkout@v7
1929
+ - name: Cypress run
1930
+ uses: cypress-io/github-action@v7
1931
+ with:
1932
+ publish-summary: false
1933
+ ```
1934
+
1935
+ ## Node.js
1936
+
1937
+ ### Support
1938
+
1939
+ Node.js is required to run this action. The recommended version `v7` supports:
1940
+
1941
+ - **Node.js** 22.x, 24.x and 26.x
1942
+
1943
+ and is generally aligned with [Node.js's release schedule](https://github.com/nodejs/Release#readme).
1944
+
1945
+ ### Usage
1946
+
1947
+ `github-action` command-type options such as [`install-command`](#custom-install-command), [`build`](#build-app), [`start`](#start-server) and [`command`](#custom-test-command) are executed with the runner's version of Node.js. You can use GitHub's [actions/setup-node](https://github.com/actions/setup-node) to install an explicit Node.js version into the runner.
1948
+
1949
+ [![Node versions example](https://github.com/cypress-io/github-action/actions/workflows/example-node-versions.yml/badge.svg)](.github/workflows/example-node-versions.yml)
1950
+
1951
+ Cypress itself runs with a fixed Node.js version specified by the [runs.using](https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#runs-for-javascript-actions) parameter of [action.yml](action.yml). `github-action@v7` uses `node24`.
1952
+
1953
+ ## Changelog
1954
+
1955
+ View the [CHANGELOG](./CHANGELOG.md) document for an overview of version changes.
1956
+
1957
+ ## Compatibility
1958
+
1959
+ - `github-action@v7` is the current recommended version, uses `node24` and is compatible with Cypress `10` and above.
1960
+ - `github-action` versions `v1` to `v6` are unsupported: they rely on Node.js `12`, `16` or `20` in End-of-life status.
1961
+
1962
+ Cypress lists browser compatibility information under [System Requirements](https://docs.cypress.io/app/get-started/install-cypress#Browsers).
1963
+
1964
+ ## Contributing
1965
+
1966
+ Please see our [Contributing Guideline](./CONTRIBUTING.md) which explains how to contribute fixes or features to the repo and how to test.
1967
+
1968
+ ## License
1969
+
1970
+ [![license][license-badge]][license-file]
1971
+
1972
+ This project is licensed under the terms of the [MIT license][license-file].
1973
+
1974
+ <!-- badge links follow -->
1975
+
1976
+ [ci-badge]: https://github.com/cypress-io/github-action/actions/workflows/main.yml/badge.svg
1977
+ [ci-workflow]: https://github.com/cypress-io/github-action/actions/workflows/main.yml
1978
+ [cloud-badge]: https://img.shields.io/endpoint?url=https://cloud.cypress.io/badge/simple/3tb7jn/master&style=flat&logo=cypress
1979
+ [cloud-project]: https://cloud.cypress.io/projects/3tb7jn/runs
1980
+ [renovate-badge]: https://img.shields.io/badge/renovate-app-blue.svg
1981
+ [renovate-bot]: https://github.com/renovatebot
1982
+ [license-badge]: https://img.shields.io/badge/license-MIT-green.svg
1983
+ [license-file]: ./LICENSE.md