Skip to content

Instantly share code, notes, and snippets.

@AlyoshaS
Created December 19, 2022 13:58
Show Gist options
  • Save AlyoshaS/daedf088a0a695c2c02349b979ceb49b to your computer and use it in GitHub Desktop.
Save AlyoshaS/daedf088a0a695c2c02349b979ceb49b to your computer and use it in GitHub Desktop.
name: ci
# https://docs.github.com/en/actions/reference/events-that-trigger-workflows
on: [deployment_status]
jobs:
e2e:
# only runs this job on successful deploy from Vercel
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: Checkout πŸ›Ž
uses: actions/checkout@v1
- name: Run Cypress 🌲
uses: cypress-io/github-action@v2
env:
CYPRESS_BASE_URL: ${{ github.event.deployment_status.target_url }}
# 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 }}"
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment