Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gr2m/73d86fec12b44160d37fb118b7eab566 to your computer and use it in GitHub Desktop.
Save gr2m/73d86fec12b44160d37fb118b7eab566 to your computer and use it in GitHub Desktop.
Example GitHub Action workflow which runs Cypress using now's deployment for the current commit. See https://mobile.twitter.com/gr2m/status/1234602143719419904
name: End-to-end tests
on: [push]
jobs:
cypress-run:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 12
# https://github.com/octokit/request-action/
- uses: octokit/request-action@v2.x
id: get_statuses
with:
route: GET /repos/:repository/commits/:ref/statuses
repository: ${{ github.repository }}
ref: ${{ github.ref }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# I assume that the most current status is set by now.
# Only works if there are no other integrations setting commit statuses (check runs don't matter)
# https://github.com/gr2m/get-json-paths-action/
- id: parse_statuses
uses: gr2m/get-json-paths-action@v1.x
with:
json: ${{ steps.get_statuses.outputs.data }}
target_url: "[0].target_url"
# replace https://zeit.co/<user>/<project>/<id>" with "<id>"
- id: get_deployment_id
run: echo "::set-output name=deployment_id::`echo ${{ steps.parse_statuses.outputs.target_url }} | cut -d "/" -f6`"
- run: echo deployment id ${{ steps.get_deployment_id.outputs.deployment_id }}
- name: Run E2E tests
uses: cypress-io/github-action@v1
with:
config: watchForFileChanges=false,baseUrl=https://my-now-app-${{ steps.get_deployment_id.outputs.deployment_id }}.now.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment