Skip to content

Workflows using Cypress Cloud fail in fork #693

@MikeMcC399

Description

@MikeMcC399

Where to find the issue

Describe the issue

If Actions are enabled in a fork, then pushing to the master branch of a fork of https://github.com/cypress-io/github-action owned by a community member causes action errors from:

The following errors are shown:

  • "Could not find Cypress test run results"
  • "You passed the --record flag but did not provide us your Record Key."

Steps to reproduce

User does not have edit access to repository https://github.com/cypress-io workflows (see GitHub help Accessing your secrets).

  1. Create a fork of https://github.com/cypress-io/github-action
  2. Clone the fork to local system
  3. upstream points to https://github.com/cypress-io/github-action, origin points to fork
  4. push to master branch on origin
  5. View action logs and note failures:
    • https://github.com/<fork-owner>/github-action/actions/workflows/example-custom-ci-build-id.yml?query=branch%3Amaster
    • https://github.com/<fork-owner>/github-action/actions/workflows/example-recording.yml?query=branch%3Amaster

Expectation

The workflows example-custom-ci-build-id and example-recording should not report additional workflow failures caused by pushing to master in a fork for external contributors who are not members of the https://github.com/cypress-io/ organization, compared to a Member pushing to https://github.com/cypress-io/github-action/tree/master.

Workaround

Disable the workflows:

in the fork to prevent failures. See GitHub help: Disabling and enabling a workflow.

Analysis

The following two workflows show the error "You passed the --record flag but did not provide us your Record Key."

A Fork owner has no access to secrets.EXAMPLE_RECORDING_KEY of the public Cypress Cloud project 3tb7jn.

The projectId is hardcoded into the corresponding Cypress config file e.g.

Alternative suggestions

Skip recording in fork

Skip running the recording workflow in a fork by adding the following:

if: github.repository == 'cypress-io/github-action'

See GitHub documentation Example: Only run job for specific repository

This could be applied to the two affected workflows.

Skip recording if secrets not defined

If secrets.EXAMPLE_RECORDING_KEY is not defined, then the recording workflows could be skipped.

Allow use of alternate Cypress Cloud project

Add secrets.EXAMPLE_PROJECT_ID to both affected workflows and set the environment variable CYPRESS_PROJECT_ID using this secret (see Project ID). The environment variable overrides any Project ID stored in the Cypress configuration file.

Add README documentation how to use this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions