# GitLab CI/CD: Deploy and Test

Run your test suite against the deployed environment to validate changes.

```yaml title=".gitlab-ci.yml"
image: node:20

stages:
  - deploy
  - test

deploy:
  stage: deploy
  script:
    - npm install
    - npx zuplo deploy --api-key "$ZUPLO_API_KEY" 2>&1 | tee ./DEPLOYMENT_STDOUT
    - echo "DEPLOYMENT_URL=$(grep -oP 'Deployed to \K(https://[^ ]+)'
      ./DEPLOYMENT_STDOUT)" >> deploy.env
  artifacts:
    reports:
      dotenv: deploy.env

test:
  stage: test
  needs:
    - deploy
  script:
    - npm install
    - npx zuplo test --endpoint "$DEPLOYMENT_URL"
```

This pipeline:

1. Deploys to Zuplo and captures the output
2. Extracts the deployment URL and passes it to the test stage
3. Runs tests against the deployed environment

## Next Steps

- Add [MR preview environments](./mr-preview-environments.mdx) with cleanup
- Run [local tests](./local-testing.mdx) before deploying
