Skip to content

Commit f4a78b6

Browse files
authored
docs: add cypress github action examples (#1123)
1 parent 0caf094 commit f4a78b6

File tree

2 files changed

+84
-1
lines changed

2 files changed

+84
-1
lines changed
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Example Cypress GitHub Actions
2+
# This example workflow demonstrates
3+
# GitHub Actions (https://docs.github.com/en/actions) using the
4+
# Cypress JavaScript GitHub Action (https://github.com/cypress-io/github-action) with
5+
# Cypress Docker images (https://github.com/cypress-io/cypress-docker-images)
6+
7+
# The workflow is triggered manually on demand, see
8+
# https://docs.github.com/en/actions/using-workflows/manually-running-a-workflow
9+
# To automatically trigger a workflow, for instance on a push event, see
10+
# https://docs.github.com/en/actions/using-workflows/triggering-a-workflow
11+
12+
on: workflow_dispatch
13+
14+
jobs:
15+
docker-base:
16+
runs-on: ubuntu-22.04
17+
container:
18+
# Examples use latest tag
19+
# For production use, to avoid the risk of breaking changes,
20+
# choose a fixed version tag from
21+
# https://hub.docker.com/r/cypress/base/tags
22+
image: cypress/base:latest
23+
# User 1001 matches the owner of the HOME directory which GitHub Actions creates
24+
# Selecting the same user minimizes permissions issues
25+
options: --user 1001
26+
steps:
27+
- uses: actions/checkout@v4
28+
- uses: cypress-io/github-action@v6
29+
with:
30+
# Only the Electron browser is available with cypress/base
31+
# This is the default browser and does not need to be specified
32+
working-directory: examples/basic
33+
34+
docker-browsers:
35+
runs-on: ubuntu-22.04
36+
strategy:
37+
# Makes sure that each browser test runs, even if any other test fails
38+
fail-fast: false
39+
matrix:
40+
browser: [chrome, edge, firefox]
41+
container:
42+
# Examples use latest tag
43+
# For production use, to avoid the risk of breaking changes,
44+
# choose a fixed version tag from
45+
# https://hub.docker.com/r/cypress/browser/tags
46+
image: cypress/browsers:latest
47+
options: --user 1001
48+
steps:
49+
- uses: actions/checkout@v4
50+
- uses: cypress-io/github-action@v6
51+
with:
52+
working-directory: examples/basic
53+
browser: ${{ matrix.browser }}
54+
55+
docker-included:
56+
runs-on: ubuntu-22.04
57+
strategy:
58+
fail-fast: false
59+
matrix:
60+
browser: [chrome, edge, firefox]
61+
# from https://hub.docker.com/r/cypress/included/tags
62+
container:
63+
# Examples use latest tag
64+
# For production use, to avoid the risk of breaking changes,
65+
# choose a fixed version tag from
66+
# https://hub.docker.com/r/cypress/included/tags
67+
image: cypress/included:latest
68+
options: --user 1001
69+
steps:
70+
- uses: actions/checkout@v4
71+
- uses: cypress-io/github-action@v6
72+
with:
73+
# Using Cypress project with no Cypress version pre-installed
74+
working-directory: examples/basic-mini
75+
browser: ${{ matrix.browser }}
76+
env:
77+
# Cypress binary is already installed in cypress/included image
78+
# Use CYPRESS_INSTALL_BINARY=0 to prevent unneeded caching
79+
# which can cause errors with non-root user
80+
# see https://on.cypress.io/guides/references/advanced-installation#Skipping-installation
81+
CYPRESS_INSTALL_BINARY: 0

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ Don't see the exact combination of Cypress, Node.js and browser versions you nee
5656

5757
## Examples
5858

59-
Check out the [README](./included/README.md) document in the [included](./included) directory for examples of how to use `cypress/included` images. (As described above, these images include all operating system dependencies, Cypress, and some browsers installed globally.)
59+
- Check out the [README](./included/README.md) document in the [included](./included) directory for examples of how to use `cypress/included` images. (As described above, these images include all operating system dependencies, Cypress, and some browsers installed globally.)
60+
61+
- See the example workflow [.github/workflows//example-cypress-github-action.yml](./.github/workflows/example-cypress-github-action.yml) for Continuous Integration (CI) using [`cypress-io/github-action`](https://github.com/cypress-io/github-action) together with Cypress Docker images.
6062

6163
## Known problems
6264

0 commit comments

Comments
 (0)