I am trying to setup a Github Actions workflow that will run Cypress tests on PR’s and pushes to master and develop branches. I was able to set everything up to work as expected for PR’s using the deploy preview URL. However, when pushing to a branch, Netlify creates a branch deploy that uses a Netlify GUID and I am not sure how to anticipate this inside of the Github Actions workflow.
I know that I can access the branch deploy using the branch name but then I wouldn’t be able to ensure that I am testing the latest build.
One way I can think of working around this issue is to turn off the Github builds option on Netlify and use a Github Action to deploy the branch instead – then I can make the deploy job a dependency before running the tests but I wanted to see if anybody had another solution.
Here is my workflow code that is working nicely for PR’s:
- uses: cypress-io/github-action@v2
env:
CYPRESS_baseUrl: 'https://deploy-preview-${{ github.event.number }}--${{ matrix.site }}.netlify.app'
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
working-directory: ${{ matrix.working_directory }}
wait-on: 'https://deploy-preview-${{ github.event.number }}--${{ matrix.site }}.netlify.app'
wait-on-timeout: 300