|
| 1 | +--- |
| 2 | +slug: /deployments/environments |
| 3 | +sidebar_label: Environments |
| 4 | +sidebar_position: 2 |
| 5 | +description: Argos provides two deployment environments—preview and production—each with its own URLs and access rules. |
| 6 | +--- |
| 7 | + |
| 8 | +import { RunPkgCommand } from "@site/src/partials"; |
| 9 | + |
| 10 | +# Environments |
| 11 | + |
| 12 | +Every deployment is created in one of two environments: |
| 13 | + |
| 14 | +- **Preview** — A non-production deployment, typically created from a feature branch or pull request. Each preview gets its own URL and never replaces the production deployment. |
| 15 | +- **Production** — The deployment served on your project's production domain. Only deployments from a production branch are promoted here. |
| 16 | + |
| 17 | +The environment is decided when the deployment is created and cannot be changed afterwards. |
| 18 | + |
| 19 | +## How the environment is determined |
| 20 | + |
| 21 | +Argos picks the environment in this order: |
| 22 | + |
| 23 | +1. **Explicit override.** If you pass `--prod` to the CLI (or `environment: "production"` to the SDK), the deployment is created as production. |
| 24 | +2. **Branch match.** Otherwise, the branch name is matched against the project's **production branch pattern**. A match → production. No match → preview. |
| 25 | + |
| 26 | +By default, the production branch pattern follows your Git repository's default branch (usually `main`). You can override it from project settings. |
| 27 | + |
| 28 | +## Preview deployments |
| 29 | + |
| 30 | +Preview deployments are the default. They are created when: |
| 31 | + |
| 32 | +- You run `argos deploy <directory>` without `--prod`, **and** |
| 33 | +- The branch does not match the production branch pattern. |
| 34 | + |
| 35 | +Each preview deployment gets: |
| 36 | + |
| 37 | +- A unique, immutable **deployment URL** — always points to that exact build. |
| 38 | +- A **branch URL** — always points to the latest preview on that branch. Useful to share a link that follows a feature branch as it evolves. |
| 39 | + |
| 40 | +See [URLs and domains](/deployments/urls) for the full list of URLs Argos generates. |
| 41 | + |
| 42 | +When a preview deployment is linked to a pull request, the deployment status appears in the [pull request comment](/pull-request-comments) and as a commit status check on the PR. |
| 43 | + |
| 44 | +## Production deployments |
| 45 | + |
| 46 | +A production deployment is created when: |
| 47 | + |
| 48 | +- You run `argos deploy <directory> --prod`, **or** |
| 49 | +- The branch matches the production branch pattern. |
| 50 | + |
| 51 | +When a new production deployment becomes ready, it is **promoted**: the project's production domain immediately starts serving the new build. Earlier production deployments remain available at their own URLs. |
| 52 | + |
| 53 | +The Argos dashboard shows a **Current** badge next to the deployment that is currently serving the production domain. |
| 54 | + |
| 55 | + |
| 56 | +_The deployments list highlights the deployment currently promoted to production._ |
| 57 | + |
| 58 | +## Configure the production branch |
| 59 | + |
| 60 | +By default, Argos uses your Git repository's default branch as the production branch. You can customize this from **Settings → Deployments → Production deployment branch**. |
| 61 | + |
| 62 | + |
| 63 | +_Project Settings → Deployments → Production deployment branch._ |
| 64 | + |
| 65 | +To customize: |
| 66 | + |
| 67 | +1. Disable **Use GitHub repository's default branch**. |
| 68 | +2. Enter a [glob pattern](https://github.com/isaacs/minimatch) that matches your production branches. |
| 69 | + |
| 70 | +Examples: |
| 71 | + |
| 72 | +- `main` — Only the `main` branch. |
| 73 | +- `{main,production}` — Either `main` or `production`. |
| 74 | +- `release/**` — Any branch under `release/` (for example `release/2024-q4`). |
| 75 | + |
| 76 | +Any branch matching the pattern produces a production deployment on the next CLI run, even without `--prod`. |
| 77 | + |
| 78 | +## Forcing an environment from the CLI |
| 79 | + |
| 80 | +You can force the environment regardless of the branch with the `--prod` flag: |
| 81 | + |
| 82 | +<RunPkgCommand command="argos deploy ./storybook-static --prod" /> |
| 83 | + |
| 84 | +This is useful when you want to: |
| 85 | + |
| 86 | +- Deploy a one-off production build from a local machine. |
| 87 | +- Promote a deployment from a non-standard branch (for example, a release branch that doesn't match the configured pattern). |
| 88 | + |
| 89 | +There is currently no flag to force a preview from a production branch—simply do not pass `--prod` and adjust the production branch pattern if needed. |
| 90 | + |
| 91 | +## Related |
| 92 | + |
| 93 | +- [Deployments overview](/deployments) |
| 94 | +- [URLs and domains](/deployments/urls) |
| 95 | +- [Use deployments in CI](/deployments/ci) |
0 commit comments