> For the complete documentation index, see [llms.txt](https://docs.crowd.dev/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.crowd.dev/docs/technical-docs/deployment.md).

# Deployment

A guide on how to deploy services to both production and staging.

## Deploy to staging

To deploy to staging, merge to the `staging-main` branch and push the code. The deployment will go through automatically! You can see the [GitHub staging deployment actions to check](https://github.com/CrowdDotDev/crowd.dev/actions/workflows/staging-deploy-backend.yaml) the status. You will also get a notification in the `deploys-staging` Slack channel once it has gone through.

* Run migrations if needed.
* Update the environment variables if needed.

## Deploy to production

The production deployment is done with a [GitHub action](https://github.com/CrowdDotDev/crowd.dev/actions/workflows/production-deploy.yaml). You can select which services you want to deploy and the branch (it should 99% of the time be `main`), and click Deploy!

* Run migrations if needed.
* Update the environment variables if needed.

## Updating environment variables

Environment variables are kept in the [kube repo](https://github.com/CrowdDotDev/kube-crowd). There is a folder for production and one for staging. There we have environment variables for frontend and backend.

To push an update to the Kubernetes cluster:

1. Make sure you have an up-to-date version of the Kube repo
2. Make the changes you want, and commit and push them! Otherwise, they could be overwritten by a colleague.
3. Run the `[production/staging]./update-config-map` script to update the values in the cluster.
4. Re-deploy the necessary services.

## Running migrations

Running database migrations is, for now, not a part of the automated deployment. They need to be run manually. To run migrations:

1. Make sure you are in the appropriate branch. If you are running them on production, this is `main`. For staging, `staging-main`. Make sure the branch is up-to-date.
2. Export the directory where crowd.dev is in your system. For example `export CROWD_CHECKOUT_DIR=/Users/joanreyero/Documents/crowd.dev`.
3. Run the script `./migrate-up.sh` to run the migrations.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.crowd.dev/docs/technical-docs/deployment.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
