Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workflows using Cypress Cloud fail in fork #693

Closed
MikeMcC399 opened this issue Dec 30, 2022 · 5 comments
Closed

Workflows using Cypress Cloud fail in fork #693

MikeMcC399 opened this issue Dec 30, 2022 · 5 comments

Comments

@MikeMcC399
Copy link
Collaborator

MikeMcC399 commented Dec 30, 2022

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.

@MikeMcC399
Copy link
Collaborator Author

MikeMcC399 commented Dec 30, 2022

@MikeMcC399
Copy link
Collaborator Author

MikeMcC399 commented Jan 12, 2023

@MikeMcC399
Copy link
Collaborator Author

Unfortunately I overlooked that Configuration variables are available in public beta only. I will modify my suggestion to use Action secrets instead and leave a migration to Configuration variables open for a future enhancement.

@MikeMcC399
Copy link
Collaborator Author

@MikeMcC399
Copy link
Collaborator Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant