> 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

## 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

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

The question should be specific, self-contained, and written in natural language.
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.
