Ephemeral Inboxes for CI Tests with Nylas CLI
Add a GitHub Action that creates a temporary Nylas inbox per PR, runs tests, and deletes the inbox.
Add the provided GitHub Action to your repo, replace secrets with your Nylas API key, and ensure the agent account creation step runs before tests
Summary
The article presents a GitHub Action that creates a fresh Nylas inbox for each pull request, runs end‑to‑end tests that require email, and tears the inbox down afterward. It replaces fragile shared Gmail aliases with a managed agent account that lives only for the duration of the test run. The workflow authenticates the CLI with an API key, creates an inbox via `nylas agent account create`, stores the email and grant ID in GitHub outputs, runs Playwright tests that poll the inbox for reset links, and finally deletes the inbox with `nylas agent account delete`. The approach eliminates shared credentials in CI, prevents test collisions, and provides real send/receive email without mocking. The article also highlights that the cleanup step runs even when tests fail, ensuring no orphaned inboxes. This pattern is ideal for teams that need isolated email environments for automated testing.
Key changes
- Create inbox with `nylas agent account create` per PR
- Store email and grant ID in GitHub outputs
- Poll inbox for reset links during tests
- Delete inbox with `nylas agent account delete` even on failure
- No shared Gmail credentials in CI
- Real send/receive email, not a mock
- Isolated inbox per test worker
- Uses Nylas CLI API key for auth