feat: [CYCLOUD-1447] Auto-detect PR numbers #2104
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: example-recording | |
# | |
# To set up this workflow to work with your own Cypress Cloud project | |
# refer to the README in the example directory examples/recording. | |
# | |
on: | |
push: | |
branches: | |
- 'master' | |
pull_request: | |
workflow_dispatch: | |
env: | |
# Set up the Cypress Cloud project ID and record key as environment variables | |
# If the Actions secret EXAMPLE_PROJECT_ID is not defined then | |
# the projectId is taken from cypress.json (v9) or cypress.config.js (v10 and later). | |
# If the Actions secret EXAMPLE_RECORDING_KEY is not defined then recording jobs are skipped. | |
CYPRESS_PROJECT_ID: ${{ secrets.EXAMPLE_PROJECT_ID }} | |
CYPRESS_RECORD_KEY: ${{ secrets.EXAMPLE_RECORDING_KEY }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
jobs: | |
check-record-key: | |
runs-on: ubuntu-22.04 | |
outputs: | |
record-key-exists: ${{ steps.record-key-check.outputs.defined }} | |
steps: | |
- name: Check for record key | |
id: record-key-check | |
run: | | |
if [ "${{ secrets.EXAMPLE_RECORDING_KEY }}" != '' ]; then | |
echo "defined=true" >> $GITHUB_OUTPUT; | |
else | |
echo "defined=false" >> $GITHUB_OUTPUT; | |
fi | |
parallel: | |
runs-on: ubuntu-22.04 | |
needs: [check-record-key] | |
strategy: | |
fail-fast: false | |
matrix: | |
# run copies of the current job in parallel | |
containers: [1, 2] | |
if: needs.check-record-key.outputs.record-key-exists == 'true' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Cypress tests | |
# normally you would write | |
# uses: cypress-io/github-action@v6 | |
uses: ./ | |
# let's give this action an ID so we can refer | |
# to its output values later | |
id: cypress | |
# Continue the build in case of an error, as we need to set the | |
# commit status in the next step, both in case of success and failure | |
continue-on-error: true | |
with: | |
working-directory: examples/recording | |
record: true | |
parallel: true | |
group: Recording example | |
tag: action | |
# see "outcome" and "conclusion" of a step doc | |
# https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#steps-context | |
# "output" can be success, failure, cancelled, or skipped | |
- name: Print Cypress Cloud URL | |
run: | | |
echo Cypress finished with: ${{ steps.cypress.outcome }} | |
echo See results at ${{ steps.cypress.outputs.resultsUrl }} | |
group: | |
runs-on: ubuntu-22.04 | |
needs: [check-record-key] | |
if: needs.check-record-key.outputs.record-key-exists == 'true' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Cypress tests | |
# normally you would write | |
# uses: cypress-io/github-action@v6 | |
uses: ./ | |
with: | |
working-directory: examples/recording | |
record: true | |
# no parallel flag, just the group name | |
group: Recording group |