Cypress End to End #647
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: Cypress End to End | |
# https://docs.github.com/en/actions/reference/events-that-trigger-workflows | |
on: [deployment_status] | |
concurrency: | |
group: ${{ github.job }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
e2e: | |
# only runs this job on successful deploy | |
if: github.event.deployment_status.state == 'success' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Print URL 🖨 | |
run: echo Testing URL ${{ github.event.deployment_status.target_url }} | |
- name: Print GitHub env variables 🖨 | |
run: npx @bahmutov/print-env GITHUB | |
- name: Checkout 🛎 | |
uses: actions/checkout@v1 | |
- name: Run Cypress 🌲 | |
uses: cypress-io/github-action@v2 | |
with: | |
record: true | |
env: | |
CYPRESS_BASE_URL: ${{ github.event.deployment_status.target_url }} | |
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} | |
# if you are NOT using Cypress GitHub Integration App, then set commit status manually | |
# https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#job-status-check-functions | |
- name: Cypress tests ✅ | |
if: ${{ success() }} | |
# set the merge commit status check | |
# using GitHub REST API | |
# see https://docs.github.com/en/rest/reference/repos#create-a-commit-status | |
run: | | |
curl --request POST \ | |
--url https://api.github.com/repos/${{ github.repository }}/statuses/${{ github.sha }} \ | |
--header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \ | |
--header 'content-type: application/json' \ | |
--data '{ | |
"context": "e2e", | |
"state": "success", | |
"description": "Cypress tests passed", | |
"target_url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" | |
}' | |
- name: Cypress tests 🚨 | |
if: ${{ failure() }} | |
run: | | |
curl --request POST \ | |
--url https://api.github.com/repos/${{ github.repository }}/statuses/${{ github.sha }} \ | |
--header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \ | |
--header 'content-type: application/json' \ | |
--data '{ | |
"context": "e2e", | |
"state": "failure", | |
"description": "Cypress tests failed", | |
"target_url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" | |
}' |