@cypress/github-action 6.2.0 → 6.4.0

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.
Files changed (3) hide show
  1. package/README.md +104 -63
  2. package/dist/index.js +76 -0
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  > [GitHub Action](https://docs.github.com/en/actions) for running [Cypress](https://www.cypress.io) end-to-end and component tests. Includes npm, pnpm and Yarn installation, custom caching and lots of configuration options.
4
4
 
5
- Placing `use: cypress-io/github-action@v5` into a GitHub Action workflow gives you a simple way to run Cypress. The action takes the project's npm, pnpm or Yarn package manager lock file, installs dependencies and caches these dependencies for future use. It then proceeds to run Cypress end-to-end tests with the built-in Electron browser and provides a test summary after completion.
5
+ Placing `use: cypress-io/github-action@v6` into a GitHub Action workflow gives you a simple way to run Cypress. The action takes the project's npm, pnpm or Yarn package manager lock file, installs dependencies and caches these dependencies for future use. It then proceeds to run Cypress end-to-end tests with the built-in Electron browser and provides a test summary after completion.
6
6
 
7
7
  If you are testing against a running server like the [Cypress Kitchen Sink showcase example](https://example.cypress.io/) on https://example.cypress.io/ no other parameters are necessary. In other cases where you need to fire up a development server, you can add the [start](#start-server) parameter to the workflow. Browse through the examples to find other useful parameters.
8
8
 
@@ -81,7 +81,7 @@ jobs:
81
81
  # Install npm dependencies, cache them correctly
82
82
  # and run all Cypress tests
83
83
  - name: Cypress run
84
- uses: cypress-io/github-action@v5
84
+ uses: cypress-io/github-action@v6
85
85
  ```
86
86
 
87
87
  [![End-to-End example](https://github.com/cypress-io/github-action/workflows/example-basic/badge.svg?branch=master)](.github/workflows/example-basic.yml)
@@ -104,7 +104,7 @@ jobs:
104
104
  - name: Checkout
105
105
  uses: actions/checkout@v3
106
106
  - name: Cypress run
107
- uses: cypress-io/github-action@v5
107
+ uses: cypress-io/github-action@v6
108
108
  with:
109
109
  component: true
110
110
  ```
@@ -121,16 +121,16 @@ Our examples specify using branch [v5](https://github.com/cypress-io/github-acti
121
121
 
122
122
  ```yml
123
123
  - name: Cypress run
124
- uses: cypress-io/github-action@v5
124
+ uses: cypress-io/github-action@v6
125
125
  ```
126
126
 
127
- When using `cypress-io/github-action@v5` from your workflow file, you will automatically use the latest [tag](https://github.com/cypress-io/github-action/tags) from branch [v5](https://github.com/cypress-io/github-action/tree/v5).
127
+ When using `cypress-io/github-action@v6` from your workflow file, you will automatically use the latest [tag](https://github.com/cypress-io/github-action/tags) from branch [v5](https://github.com/cypress-io/github-action/tree/v5).
128
128
 
129
129
  Alternatively, to mitigate unforeseen breaks, bind to a specific [tag](https://github.com/cypress-io/github-action/tags), for example:
130
130
 
131
131
  ```yml
132
132
  - name: Cypress run
133
- uses: cypress-io/github-action@v5.1.0
133
+ uses: cypress-io/github-action@v6.1.0
134
134
  ```
135
135
 
136
136
  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) for an overview of major changes.
@@ -150,7 +150,7 @@ jobs:
150
150
  name: E2E on Chrome
151
151
  steps:
152
152
  - uses: actions/checkout@v3
153
- - uses: cypress-io/github-action@v5
153
+ - uses: cypress-io/github-action@v6
154
154
  with:
155
155
  browser: chrome
156
156
  ```
@@ -168,7 +168,7 @@ jobs:
168
168
  name: E2E on Firefox
169
169
  steps:
170
170
  - uses: actions/checkout@v3
171
- - uses: cypress-io/github-action@v5
171
+ - uses: cypress-io/github-action@v6
172
172
  with:
173
173
  browser: firefox
174
174
  ```
@@ -186,7 +186,7 @@ jobs:
186
186
  name: E2E on Edge
187
187
  steps:
188
188
  - uses: actions/checkout@v3
189
- - uses: cypress-io/github-action@v5
189
+ - uses: cypress-io/github-action@v6
190
190
  with:
191
191
  browser: edge
192
192
  ```
@@ -205,7 +205,7 @@ jobs:
205
205
  runs-on: ubuntu-22.04
206
206
  steps:
207
207
  - uses: actions/checkout@v3
208
- - uses: cypress-io/github-action@v5
208
+ - uses: cypress-io/github-action@v6
209
209
  with:
210
210
  browser: chrome
211
211
  headed: true
@@ -228,7 +228,7 @@ jobs:
228
228
  options: --user 1001
229
229
  steps:
230
230
  - uses: actions/checkout@v3
231
- - uses: cypress-io/github-action@v5
231
+ - uses: cypress-io/github-action@v6
232
232
  with:
233
233
  browser: chrome
234
234
  ```
@@ -254,7 +254,7 @@ jobs:
254
254
  uses: actions/checkout@v3
255
255
 
256
256
  - name: Cypress run with env
257
- uses: cypress-io/github-action@v5
257
+ uses: cypress-io/github-action@v6
258
258
  with:
259
259
  env: host=api.dev.local,port=4222
260
260
  ```
@@ -272,7 +272,7 @@ jobs:
272
272
  uses: actions/checkout@v3
273
273
 
274
274
  - name: Cypress run with env
275
- uses: cypress-io/github-action@v5
275
+ uses: cypress-io/github-action@v6
276
276
  env:
277
277
  CYPRESS_host: api.dev.local
278
278
  CYPRESS_port: 4222
@@ -298,7 +298,7 @@ jobs:
298
298
  uses: actions/checkout@v3
299
299
 
300
300
  - name: Cypress run
301
- uses: cypress-io/github-action@v5
301
+ uses: cypress-io/github-action@v6
302
302
  with:
303
303
  spec: cypress/e2e/spec1.cy.js
304
304
  ```
@@ -328,7 +328,7 @@ jobs:
328
328
  - name: Checkout
329
329
  uses: actions/checkout@v3
330
330
  - name: Cypress run
331
- uses: cypress-io/github-action@v5
331
+ uses: cypress-io/github-action@v6
332
332
  with:
333
333
  project: ./some/nested/folder
334
334
  ```
@@ -351,7 +351,7 @@ jobs:
351
351
  uses: actions/checkout@v3
352
352
 
353
353
  - name: Cypress run
354
- uses: cypress-io/github-action@v5
354
+ uses: cypress-io/github-action@v6
355
355
  with:
356
356
  record: true
357
357
  env:
@@ -383,7 +383,7 @@ jobs:
383
383
  uses: actions/checkout@v3
384
384
 
385
385
  - name: Cypress run
386
- uses: cypress-io/github-action@v5
386
+ uses: cypress-io/github-action@v6
387
387
  with:
388
388
  record: true
389
389
  env:
@@ -421,7 +421,7 @@ jobs:
421
421
  uses: actions/checkout@v3
422
422
 
423
423
  - name: Cypress run
424
- uses: cypress-io/github-action@v5
424
+ uses: cypress-io/github-action@v6
425
425
  with:
426
426
  record: true
427
427
  tag: node-${{ matrix.node }}
@@ -457,7 +457,7 @@ jobs:
457
457
  uses: actions/checkout@v3
458
458
 
459
459
  - name: Cypress run
460
- uses: cypress-io/github-action@v5
460
+ uses: cypress-io/github-action@v6
461
461
  with:
462
462
  record: true
463
463
  # Cancel the run after 2 failed tests
@@ -482,7 +482,7 @@ jobs:
482
482
  name: Artifacts
483
483
  steps:
484
484
  - uses: actions/checkout@v3
485
- - uses: cypress-io/github-action@v5
485
+ - uses: cypress-io/github-action@v6
486
486
  # after the test run completes store videos and any screenshots
487
487
  - uses: actions/upload-artifact@v3
488
488
  # add the line below to store screenshots only on failures
@@ -538,7 +538,7 @@ jobs:
538
538
  uses: actions/checkout@v3
539
539
 
540
540
  - name: Cypress run
541
- uses: cypress-io/github-action@v5
541
+ uses: cypress-io/github-action@v6
542
542
  with:
543
543
  config: pageLoadTimeout=100000,baseUrl=http://localhost:3000
544
544
  ```
@@ -561,7 +561,7 @@ jobs:
561
561
  uses: actions/checkout@v3
562
562
 
563
563
  - name: Cypress run
564
- uses: cypress-io/github-action@v5
564
+ uses: cypress-io/github-action@v6
565
565
  with:
566
566
  config-file: tests/cypress-config.json
567
567
  ```
@@ -595,7 +595,7 @@ jobs:
595
595
  # because of "record" and "parallel" parameters
596
596
  # these containers will load balance all found tests among themselves
597
597
  - name: Cypress run
598
- uses: cypress-io/github-action@v5
598
+ uses: cypress-io/github-action@v6
599
599
  with:
600
600
  record: true
601
601
  parallel: true
@@ -622,10 +622,10 @@ During staged rollout of a new GitHub-hosted runner version, GitHub may provide
622
622
 
623
623
  ```yml
624
624
  - name: Run E2E tests
625
- uses: cypress-io/github-action@v5
625
+ uses: cypress-io/github-action@v6
626
626
 
627
627
  - name: Run Component Testing
628
- uses: cypress-io/github-action@v5
628
+ uses: cypress-io/github-action@v6
629
629
  with:
630
630
  # we have already installed everything
631
631
  install: false
@@ -648,7 +648,7 @@ jobs:
648
648
  - name: Checkout
649
649
  uses: actions/checkout@v3
650
650
  - name: Cypress run
651
- uses: cypress-io/github-action@v5
651
+ uses: cypress-io/github-action@v6
652
652
  with:
653
653
  build: npm run build
654
654
  ```
@@ -667,7 +667,7 @@ jobs:
667
667
  - name: Checkout
668
668
  uses: actions/checkout@v3
669
669
  - name: Cypress run
670
- uses: cypress-io/github-action@v5
670
+ uses: cypress-io/github-action@v6
671
671
  with:
672
672
  start: npm start
673
673
  ```
@@ -685,7 +685,7 @@ jobs:
685
685
  - name: Checkout
686
686
  uses: actions/checkout@v3
687
687
  - name: Cypress run
688
- uses: cypress-io/github-action@v5
688
+ uses: cypress-io/github-action@v6
689
689
  with:
690
690
  # Linux and MacOS
691
691
  start: npm start
@@ -711,7 +711,7 @@ jobs:
711
711
  - name: Checkout
712
712
  uses: actions/checkout@v3
713
713
  - name: Cypress run
714
- uses: cypress-io/github-action@v5
714
+ uses: cypress-io/github-action@v6
715
715
  with:
716
716
  start: npm run api, npm run web
717
717
  ```
@@ -741,7 +741,7 @@ jobs:
741
741
  - name: Checkout
742
742
  uses: actions/checkout@v3
743
743
  - name: Cypress run
744
- uses: cypress-io/github-action@v5
744
+ uses: cypress-io/github-action@v6
745
745
  with:
746
746
  start: npm start
747
747
  # quote the url to be safe against YML parsing surprises
@@ -755,7 +755,7 @@ jobs:
755
755
  By default, `wait-on` will retry for 60 seconds. You can pass a custom timeout in seconds using `wait-on-timeout`.
756
756
 
757
757
  ```yml
758
- - uses: cypress-io/github-action@v5
758
+ - uses: cypress-io/github-action@v6
759
759
  with:
760
760
  start: npm start
761
761
  wait-on: 'http://localhost:8080/status'
@@ -768,7 +768,7 @@ By default, `wait-on` will retry for 60 seconds. You can pass a custom timeout i
768
768
  You can wait for multiple URLs to respond by separating urls with a comma
769
769
 
770
770
  ```yml
771
- - uses: cypress-io/github-action@v5
771
+ - uses: cypress-io/github-action@v6
772
772
  with:
773
773
  # API runs on port 3050
774
774
  # Web server runs on port 8080
@@ -782,7 +782,7 @@ The action will wait for the first url to respond, then will check the second ur
782
782
  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:
783
783
 
784
784
  ```yml
785
- - uses: cypress-io/github-action@v5
785
+ - uses: cypress-io/github-action@v6
786
786
  with:
787
787
  start: npm start
788
788
  wait-on: 'npx wait-on --timeout 60000 http://localhost:3000'
@@ -805,7 +805,7 @@ Under Node.js version 18 and later, `wait-on` may fail to recognize that a `loca
805
805
  If you want to overwrite the install command
806
806
 
807
807
  ```yml
808
- - uses: cypress-io/github-action@v5
808
+ - uses: cypress-io/github-action@v6
809
809
  with:
810
810
  install-command: yarn --frozen-lockfile --silent
811
811
  ```
@@ -826,7 +826,7 @@ jobs:
826
826
  - name: Checkout
827
827
  uses: actions/checkout@v3
828
828
  - name: Cypress run
829
- uses: cypress-io/github-action@v5
829
+ uses: cypress-io/github-action@v6
830
830
  with:
831
831
  start: npm start
832
832
  # quote the url to be safe against YML parsing surprises
@@ -846,7 +846,7 @@ steps:
846
846
  uses: actions/checkout@v3
847
847
 
848
848
  - name: Custom tests 🧪
849
- uses: cypress-io/github-action@v5
849
+ uses: cypress-io/github-action@v6
850
850
  with:
851
851
  command: npm run e2e:ci
852
852
  ```
@@ -871,7 +871,7 @@ jobs:
871
871
  containers: [1, 2, 3]
872
872
  steps:
873
873
  - uses: actions/checkout@v3
874
- - uses: cypress-io/github-action@v5
874
+ - uses: cypress-io/github-action@v6
875
875
  with:
876
876
  record: true
877
877
  parallel: true
@@ -906,7 +906,7 @@ jobs:
906
906
  needs: ['prepare']
907
907
  steps:
908
908
  - uses: actions/checkout@v3
909
- - uses: cypress-io/github-action@v5
909
+ - uses: cypress-io/github-action@v6
910
910
  with:
911
911
  record: true
912
912
  parallel: true
@@ -946,7 +946,7 @@ jobs:
946
946
  runs-on: ubuntu-22.04
947
947
  steps:
948
948
  - uses: actions/checkout@v3
949
- - uses: cypress-io/github-action@v5
949
+ - uses: cypress-io/github-action@v6
950
950
  with:
951
951
  start: npm start
952
952
  working-directory: app-test
@@ -992,7 +992,7 @@ jobs:
992
992
 
993
993
  # Cypress has its own package.json in folder "e2e"
994
994
  - name: Install Cypress and run tests
995
- uses: cypress-io/github-action@v5
995
+ uses: cypress-io/github-action@v6
996
996
  with:
997
997
  working-directory: e2e
998
998
  ```
@@ -1015,7 +1015,7 @@ jobs:
1015
1015
  with:
1016
1016
  version: 8
1017
1017
  - name: Cypress run
1018
- uses: cypress-io/github-action@v5
1018
+ uses: cypress-io/github-action@v6
1019
1019
  with:
1020
1020
  working-directory: examples/basic-pnpm
1021
1021
  ```
@@ -1036,7 +1036,7 @@ jobs:
1036
1036
  - name: Checkout
1037
1037
  uses: actions/checkout@v3
1038
1038
  - name: Cypress run
1039
- uses: cypress-io/github-action@v5
1039
+ uses: cypress-io/github-action@v6
1040
1040
  with:
1041
1041
  working-directory: examples/yarn-classic
1042
1042
  ```
@@ -1057,7 +1057,7 @@ jobs:
1057
1057
  - name: Checkout
1058
1058
  uses: actions/checkout@v3
1059
1059
  - name: Cypress run
1060
- uses: cypress-io/github-action@v5
1060
+ uses: cypress-io/github-action@v6
1061
1061
  with:
1062
1062
  working-directory: examples/yarn-modern
1063
1063
  install-command: yarn install
@@ -1082,7 +1082,7 @@ jobs:
1082
1082
  - name: Checkout
1083
1083
  uses: actions/checkout@v3
1084
1084
  - name: Cypress run
1085
- uses: cypress-io/github-action@v5
1085
+ uses: cypress-io/github-action@v6
1086
1086
  with:
1087
1087
  working-directory: examples/yarn-modern-pnp
1088
1088
  install-command: yarn install
@@ -1110,7 +1110,7 @@ jobs:
1110
1110
  runs-on: ubuntu-22.04
1111
1111
  steps:
1112
1112
  - uses: actions/checkout@v3
1113
- - uses: cypress-io/github-action@v5
1113
+ - uses: cypress-io/github-action@v6
1114
1114
  with:
1115
1115
  working-directory: examples/start-and-yarn-workspaces/workspace-1
1116
1116
  build: yarn run build
@@ -1145,7 +1145,7 @@ jobs:
1145
1145
  # run Cypress tests and record them under the same run
1146
1146
  # associated with commit SHA and just give a different group name
1147
1147
  - name: Cypress run
1148
- uses: cypress-io/github-action@v5
1148
+ uses: cypress-io/github-action@v6
1149
1149
  with:
1150
1150
  record: true
1151
1151
  group: Tests on Node v${{ matrix.node }}
@@ -1174,7 +1174,7 @@ jobs:
1174
1174
  with:
1175
1175
  node-version: ${{ matrix.node }}
1176
1176
  - uses: actions/checkout@v3
1177
- - uses: cypress-io/github-action@v5
1177
+ - uses: cypress-io/github-action@v6
1178
1178
  ```
1179
1179
 
1180
1180
  See the [Node.js](#nodejs) section for information about supported versions and usage of Node.js.
@@ -1194,13 +1194,13 @@ jobs:
1194
1194
  steps:
1195
1195
  - uses: actions/checkout@master
1196
1196
  - name: Install dependencies
1197
- uses: cypress-io/github-action@v5
1197
+ uses: cypress-io/github-action@v6
1198
1198
  with:
1199
1199
  # just perform install
1200
1200
  runTests: false
1201
1201
  - run: yarn lint
1202
1202
  - name: Run e2e tests
1203
- uses: cypress-io/github-action@v5
1203
+ uses: cypress-io/github-action@v6
1204
1204
  with:
1205
1205
  # we have already installed all dependencies above
1206
1206
  install: false
@@ -1227,7 +1227,7 @@ If the project has many dependencies, but you want to install just Cypress you c
1227
1227
  node_modules
1228
1228
  key: my-cache-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
1229
1229
  - run: npm i cypress
1230
- - uses: cypress-io/github-action@v5
1230
+ - uses: cypress-io/github-action@v6
1231
1231
  with:
1232
1232
  install: false
1233
1233
  ```
@@ -1247,7 +1247,7 @@ jobs:
1247
1247
  timeout-minutes: 10
1248
1248
  steps:
1249
1249
  - uses: actions/checkout@v3
1250
- - uses: cypress-io/github-action@v5
1250
+ - uses: cypress-io/github-action@v6
1251
1251
  # you can specify individual step timeout too
1252
1252
  timeout-minutes: 5
1253
1253
  ```
@@ -1290,7 +1290,7 @@ You can set the environment variable using GitHub UI interface, or in the workfl
1290
1290
 
1291
1291
  ```yml
1292
1292
  - name: Cypress tests with debug logs
1293
- uses: cypress-io/github-action@v5
1293
+ uses: cypress-io/github-action@v6
1294
1294
  env:
1295
1295
  DEBUG: '@cypress/github-action'
1296
1296
  ```
@@ -1303,7 +1303,7 @@ The above `ACTIONS_STEP_DEBUG` setting enables the debug logs from the action it
1303
1303
 
1304
1304
  ```yml
1305
1305
  - name: Cypress tests with debug logs
1306
- uses: cypress-io/github-action@v5
1306
+ uses: cypress-io/github-action@v6
1307
1307
  env:
1308
1308
  DEBUG: 'cypress:*'
1309
1309
  ```
@@ -1349,7 +1349,7 @@ This is an example of using the step output `resultsUrl`:
1349
1349
 
1350
1350
  ```yml
1351
1351
  - name: Cypress tests
1352
- uses: cypress-io/github-action@v5
1352
+ uses: cypress-io/github-action@v6
1353
1353
  # let's give this action an ID so we can refer
1354
1354
  # to its output values later
1355
1355
  id: cypress
@@ -1388,7 +1388,7 @@ jobs:
1388
1388
  - name: Checkout
1389
1389
  uses: actions/checkout@v3
1390
1390
  - name: Cypress run
1391
- uses: cypress-io/github-action@v5
1391
+ uses: cypress-io/github-action@v6
1392
1392
  with:
1393
1393
  build: npx cypress info
1394
1394
  ```
@@ -1405,14 +1405,14 @@ jobs:
1405
1405
  - name: Checkout
1406
1406
  uses: actions/checkout@v3
1407
1407
  - name: Cypress install
1408
- uses: cypress-io/github-action@v5
1408
+ uses: cypress-io/github-action@v6
1409
1409
  with:
1410
1410
  # just perform install
1411
1411
  runTests: false
1412
1412
  - name: Cypress info
1413
1413
  run: npx cypress info
1414
1414
  - name: Cypress run
1415
- uses: cypress-io/github-action@v5
1415
+ uses: cypress-io/github-action@v6
1416
1416
  with:
1417
1417
  # we have already installed all dependencies above
1418
1418
  install: false
@@ -1436,7 +1436,7 @@ jobs:
1436
1436
  - name: Checkout
1437
1437
  uses: actions/checkout@v3
1438
1438
  - name: Cypress nightly tests 🌃
1439
- uses: cypress-io/github-action@v5
1439
+ uses: cypress-io/github-action@v6
1440
1440
  ```
1441
1441
 
1442
1442
  [![cron example](https://github.com/cypress-io/github-action/workflows/example-cron/badge.svg?branch=master)](.github/workflows/example-cron.yml)
@@ -1457,16 +1457,57 @@ jobs:
1457
1457
  - name: Checkout
1458
1458
  uses: actions/checkout@v3
1459
1459
  - name: Cypress run
1460
- uses: cypress-io/github-action@v5
1460
+ uses: cypress-io/github-action@v6
1461
1461
  with:
1462
1462
  publish-summary: false
1463
1463
  ```
1464
1464
 
1465
+ ### Automatic PR number & URL detection
1466
+
1467
+ When recording runs to Cypress Cloud, the PR number and URL can be automatically detected if you pass `GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}`
1468
+ 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
1469
+ exist) and sets them in the environment variables `CYPRESS_PULL_REQUEST_ID` and `CYPRESS_PULL_REQUEST_URL`, respectively.
1470
+ * See Cypress' documentation on [CI Build Information](https://on.cypress.io/guides/continuous-integration/introduction#CI-Build-Information)
1471
+
1472
+ Example workflow using the variables:
1473
+ ```yml
1474
+ name: Example echo PR number and URL
1475
+ on: push
1476
+ jobs:
1477
+ cypress-run:
1478
+ runs-on: ubuntu-22.04
1479
+ steps:
1480
+ - name: Checkout
1481
+ uses: actions/checkout@v3
1482
+ - name: Cypress run
1483
+ uses: cypress-io/github-action@v6
1484
+ with:
1485
+ record: true
1486
+ - run: echo "PR number is $CYPRESS_PULL_REQUEST_ID"
1487
+ - run: echo "PR URL is $CYPRESS_PULL_REQUEST_URL"
1488
+ env:
1489
+ CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
1490
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1491
+ ```
1492
+
1493
+ #### Triggering event: `pull_request`/`pull_request_target`
1494
+
1495
+ 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
1496
+ PR that triggered the workflow.
1497
+
1498
+ #### Triggering event: `push`
1499
+
1500
+ 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
1501
+ 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
1502
+ and use that PR's number and URL for `CYPRESS_PULL_REQUEST_ID` and `CYPRESS_PULL_REQUEST_URL`, respectively.
1503
+
1504
+ If no related PR is detected, `CYPRESS_PULL_REQUEST_ID` and `CYPRESS_PULL_REQUEST_URL` will be undefined.
1505
+
1465
1506
  ## Node.js
1466
1507
 
1467
1508
  ### Support
1468
1509
 
1469
- Node.js is required to run this action. The currently recommended version `v5` supports:
1510
+ Node.js is required to run this action. The recommended version `v6` supports:
1470
1511
 
1471
1512
  - **Node.js** 16.x
1472
1513
  - **Node.js** 18.x
@@ -1488,9 +1529,9 @@ View the [CHANGELOG](./CHANGELOG.md) document for an overview of version changes
1488
1529
 
1489
1530
  ## Compatibility
1490
1531
 
1491
- - `v6` is provided for early adopters needing full `node20` support
1492
- - `v5` is the current recommended version
1493
- - `v4` is the minimum version required for Cypress `10.x` and later
1532
+ - `v6` is the current recommended version and uses `node20`
1533
+ - `v5` uses `node16`
1534
+ - `v4` is the minimum version required for Cypress `10.x` and later - also uses `node16`
1494
1535
 
1495
1536
  Pay attention to any GitHub Actions deprecation warnings shown in logs which may recommend updating.
1496
1537
 
package/dist/index.js CHANGED
@@ -74832,6 +74832,80 @@ const waitOnMaybe = () => {
74832
74832
 
74833
74833
  const I = (x) => x
74834
74834
 
74835
+ const detectPrNumber = async () => {
74836
+ const {
74837
+ GITHUB_SHA,
74838
+ GITHUB_TOKEN,
74839
+ GITHUB_RUN_ID,
74840
+ GITHUB_REPOSITORY,
74841
+ GITHUB_HEAD_REF,
74842
+ GITHUB_REF,
74843
+ GITHUB_SERVER_URL,
74844
+ CYPRESS_PULL_REQUEST_ID,
74845
+ CYPRESS_PULL_REQUEST_URL
74846
+ } = process.env
74847
+
74848
+ if (CYPRESS_PULL_REQUEST_ID && CYPRESS_PULL_REQUEST_URL) {
74849
+ // Both pull request envs are already defined - no need to do anything else
74850
+ return
74851
+ }
74852
+
74853
+ const [owner, repo] = GITHUB_REPOSITORY.split('/')
74854
+ let prNumber
74855
+
74856
+ if (GITHUB_TOKEN) {
74857
+ debug(
74858
+ `Detecting PR number by asking GitHub about run ${GITHUB_RUN_ID}`
74859
+ )
74860
+
74861
+ const client = new Octokit({
74862
+ auth: GITHUB_TOKEN
74863
+ })
74864
+
74865
+ if (GITHUB_HEAD_REF) {
74866
+ // GITHUB_HEAD_REF is only defined when the event that triggered it was 'pull_request' or 'pull_request_target' (meaning a PR number should be readily-available)
74867
+ // should have format refs/pull/<pr_number>/merge when triggered by pull_request workflow
74868
+ prNumber = parseInt(GITHUB_REF.split('/')[2])
74869
+ } else {
74870
+ try {
74871
+ const resp = await client.request(
74872
+ 'GET /repos/:owner/:repo/commits/:commit_sha/pulls',
74873
+ {
74874
+ owner,
74875
+ repo,
74876
+ commit_sha: GITHUB_SHA
74877
+ }
74878
+ )
74879
+
74880
+ if (
74881
+ resp &&
74882
+ resp.data &&
74883
+ resp.data[0] &&
74884
+ resp.data[0].number
74885
+ ) {
74886
+ prNumber = resp.data[0].number
74887
+ }
74888
+ } catch (e) {
74889
+ console.error(
74890
+ `Unable to fetch related PR data for commit: '${GITHUB_SHA}': `,
74891
+ e
74892
+ )
74893
+ }
74894
+ }
74895
+
74896
+ if (prNumber) {
74897
+ if (!CYPRESS_PULL_REQUEST_ID) {
74898
+ core.exportVariable('CYPRESS_PULL_REQUEST_ID', prNumber)
74899
+ }
74900
+
74901
+ const url = `${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/pull/${prNumber}`
74902
+ if (!CYPRESS_PULL_REQUEST_URL) {
74903
+ core.exportVariable('CYPRESS_PULL_REQUEST_URL', url)
74904
+ }
74905
+ }
74906
+ }
74907
+ }
74908
+
74835
74909
  /**
74836
74910
  * Asks Cypress API if there were already builds for this commit.
74837
74911
  * In that case increments the count to get unique parallel id.
@@ -75065,6 +75139,8 @@ const runTests = async () => {
75065
75139
  core.exportVariable('CYPRESS_CACHE_FOLDER', CYPRESS_CACHE_FOLDER)
75066
75140
  core.exportVariable('TERM', 'xterm')
75067
75141
 
75142
+ await detectPrNumber()
75143
+
75068
75144
  if (customCommand) {
75069
75145
  console.log('Using custom test command: %s', customCommand)
75070
75146
  return execCommand(customCommand, true, 'run tests')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cypress/github-action",
3
- "version": "6.2.0",
3
+ "version": "6.4.0",
4
4
  "description": "GitHub Action for running Cypress end-to-end and component tests",
5
5
  "private": false,
6
6
  "main": "dist/index.js",