GitHub Actions
Keep the API key out of the repository: store it as a secret, and the project id and domain as variables, then pass them to the tests.
- In the console, create a key for the project used by CI (read and delete is enough).
- In the repository on GitHub: Settings, Secrets and variables, Actions. Add the secret
WAITFORMAIL_API_KEY, and the variablesWAITFORMAIL_PROJECTandWAITFORMAIL_DOMAIN. - Add the workflow:
# .github/workflows/e2e.yml
name: e2e
on: [push, pull_request]
jobs:
e2e:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
with:
node-version: 22
cache: npm
- run: npm ci
- run: npx playwright install --with-deps chromium
- run: npx playwright test
env:
WAITFORMAIL_API_KEY: ${{ secrets.WAITFORMAIL_API_KEY }}
WAITFORMAIL_PROJECT: ${{ vars.WAITFORMAIL_PROJECT }}
WAITFORMAIL_DOMAIN: ${{ vars.WAITFORMAIL_DOMAIN }}For Cypress, replace the last two steps with cypress-io/github-action and give the same values
the CYPRESS_ prefix:
- uses: cypress-io/github-action@v6
env:
CYPRESS_WAITFORMAIL_API_KEY: ${{ secrets.WAITFORMAIL_API_KEY }}
CYPRESS_WAITFORMAIL_PROJECT: ${{ vars.WAITFORMAIL_PROJECT }}
CYPRESS_WAITFORMAIL_DOMAIN: ${{ vars.WAITFORMAIL_DOMAIN }}Pull requests from forks do not get secrets, so their email tests cannot reach the API. Skip them
there (if: github.event.pull_request.head.repo.fork == false) or run them after merging.
The application under test sends its email from wherever it runs, here the GitHub runner, through its normal provider or through the SMTP trap.